Linux服务器中验证码图片不显示的几种情况 Could not initialize class sun.awt.X11GraphicsEnvironment
日志报错如下:
Oops: NoClassDefFoundError
An unexpected error occured caused by exception NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
play.exceptions.UnexpectedException: Unexpected Error
at play.Invoker$Invocation.onException(Invoker.java:244)
at play.Invoker$Invocation.run(Invoker.java:286)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:195)
at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:102)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:81)
at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1182)
at jj.play.ns.nl.captcha.backgrounds.TransparentBackgroundProducer.getBackground(Unknown Source)
at jj.play.ns.nl.captcha.backgrounds.TransparentBackgroundProducer.addBackground(Unknown Source)
at play.libs.Images$Captcha.check(Images.java:316)
at play.libs.Images$Captcha.read(Images.java:304)
at play.mvc.results.RenderBinary.apply(RenderBinary.java:169)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:252)
… 1 more
16:06:17,181 ERROR ~
项目介绍:该项目使用的是play框架,部署时没有使用容器(tomcat等),直接使用play命令去部署启动。
在网上搜了一些关于这个问题的答案,基本上很统一,都是需要在容器中添加如下配置:
-Djava.awt.headless=true \
但是,我的问题不是如此解决的:
造成这个问题的原因是因为xshell连接时属性配置问题,如下图:
还没有评论,来说两句吧...