赞
踩
- Caused by: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManagerat java.lang.Class.forName0(Native Method)
- at java.lang.Class.forName(Class.java:348)
- at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:82)
- at java.security.AccessController.doPrivileged(Native Method)
- at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
- at java.awt.Font.getFont2D(Font.java:491)
- at java.awt.Font.access$000(Font.java:224)
- at java.awt.Font$FontAccessImpl.getFont2D(Font.java:228)
- at sun.font.FontUtilities.getFont2D(FontUtilities.java:180)
- at sun.java2d.SunGraphics2D.checkFontInfo(SunGraphics2D.java:669)
- at sun.java2d.SunGraphics2D.getFontInfo(SunGraphics2D.java:830)
- at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:50)
- at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2928)
- at com.ktnw.common.utils.RandomValidateCodeUtil.drowString(RandomValidateCodeUtil.java:101)
- at com.ktnw.common.utils.RandomValidateCodeUtil.getRandcode(RandomValidateCodeUtil.java:74)
- at com.ktnw.system.controller.LoginController.getVerify(LoginController.java:125)
- at com.ktnw.system.controller.LoginController$$FastClassBySpringCGLIB$$36dcbfa3.invoke(<generated>)
- at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
- at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)
- at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
- at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
- at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
- 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 生效了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。