当前位置:   article > 正文

【已解决】Could not initialize class sun.awt.X11FontManager

could not initialize class sun.awt.x11fontmanager
  1. Caused by: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManagerat java.lang.Class.forName0(Native Method)
  2. at java.lang.Class.forName(Class.java:348)
  3. at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:82)
  4. at java.security.AccessController.doPrivileged(Native Method)
  5. at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
  6. at java.awt.Font.getFont2D(Font.java:491)
  7. at java.awt.Font.access$000(Font.java:224)
  8. at java.awt.Font$FontAccessImpl.getFont2D(Font.java:228)
  9. at sun.font.FontUtilities.getFont2D(FontUtilities.java:180)
  10. at sun.java2d.SunGraphics2D.checkFontInfo(SunGraphics2D.java:669)
  11. at sun.java2d.SunGraphics2D.getFontInfo(SunGraphics2D.java:830)
  12. at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:50)
  13. at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2928)
  14. at com.ktnw.common.utils.RandomValidateCodeUtil.drowString(RandomValidateCodeUtil.java:101)
  15. at com.ktnw.common.utils.RandomValidateCodeUtil.getRandcode(RandomValidateCodeUtil.java:74)
  16. at com.ktnw.system.controller.LoginController.getVerify(LoginController.java:125)
  17. at com.ktnw.system.controller.LoginController$$FastClassBySpringCGLIB$$36dcbfa3.invoke(<generated>)
  18. at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
  19. at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)
  20. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
  21. at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
  22. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
  23. at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)

用的是Docker 运行java -jar,发现此问题。原因是用的JDK 是open-jdk的slim 版本。

后来替换成Oracel jdk 就行了。

可以使用docker search jdk 命令,然后查看jdk 是open jdk 还是oracle jdk

最后确定使用 gmaslowski/jre:8  更多版本可以查看https://github.com/gmaslowski/docker-java

 

PS:

搜索网上有提示说在java 后面加上这个运行参数也可以解决:-Djava.awt.headless=true

例如: java -Djava.awt.headless=true -jar abc.jar

我是换成了Oracle jdk,也加了这个参数(单独加这个参数的时候不生效)。估计是oracle jdk 生效了。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/195570
推荐阅读
相关标签
  

闽ICP备14008679号