Exception in thread “http-bio-8080-exec-9” java.lang.InternalError: Can’t connect to X11 window server using ‘localhost:10.0’ as the value of the DISPLAY variable.

at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)

at sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52)

at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155)

at java.security.AccessController.doPrivileged(Native Method)

at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:171)

at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)

at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1135)

at java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1125)

at caff.util.vcode.ImageVcodeUtil.getVcodeInner(ImageVcodeUtil.java:72)

at caff.util.vcode.ImageVcodeUtil.getVcode(ImageVcodeUtil.java:36)

at caff.web.servlet.vcodeimage.ImageVcodeServlet.doGet(ImageVcodeServlet.java:25)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

原因分析:因为用到图像处理,JAVA程序会去寻找Linux上的图形界面是否启动。

解决:不让java去寻找Linux图形界面即可,在java启动的时候加入:java -Djava.awt.headless=true

实现:在tomcat配置文件中/usr/local/tomcat/bin/catalina.sh中任意段添加:

JAVA_OPTS=-Djava.awt.headless=true

echo “Using CATALINA_BASE:   $CATALINA_BASE”
echo “Using CATALINA_HOME:   $CATALINA_HOME”
echo “Using CATALINA_TMPDIR: $CATALINA_TMPDIR”
echo “Using RUNJAVA:       $_RUNJAVA”
echo “Using JAVA_OPTS:  $JAVA_OPTS”

重启之后JAVA启动不再需要检测。2015111101

 

发表评论

后才能评论