错误信息:
2021-12-06 17:09:46.137 ERROR 44175 --- [nio-8088-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.InternalError: java.lang.reflect.InvocationTargetException] with root cause
Caused by: java.lang.NullPointerException: Cannot load from short array because "sun.awt.FontConfiguration.head" is null
at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1262) ~[na:na]
at java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:224) ~[na:na]
at java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:106) ~[na:na]
at java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:706) ~[na:na]
at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:358) ~[na:na]
at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:315) ~[na:na]
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318) ~[na:na]
at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:315) ~[na:na]
at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35) ~[na:na]
at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56) ~[na:na]
... 65 common frames omitted
原因:系统缺少相应的字体库,我们只需要使用如下命令安装字体库即可得到解决。
yum install fontconfig
fc-cache --force
安装完后在/usr/shared
目录就可以看到fonts
和fontconfig
两个目录。
然后重启项目,验证码能正常获取了并且后端也不再报错了。