linux部署JAVA应用验证码生成失败

linux部署JAVA应用验证码生成失败

记部署服务时遇到的问题

linux部署JAVA应用验证码生成失败
验证码采用awt图形处理并内存中生成(代码如下),java程序会去寻找linux上的图形界面是否启动 ,如linux缺少组件则检测报错

Caused by: javax.servlet.ServletException: java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
        at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:909)
        at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:838)
        at org.apache.jsp.commons.imageLogin2_jsp._jspService(imageLogin2_jsp.java:194)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
        ... 58 more

解决方式:

tomca直接跑应用 在catalina.sh文件中加入:

CATALINA_OPTS="$CATALINA_OPTS -Djava.awt.headless=true " 

部署方式(引用tomcat)则在setenv.sh总加入:

export CATALINA_OPTS="-Djava.awt.headless=true

备注:个人博客同步至。

你可能感兴趣的:(linux部署JAVA应用验证码生成失败)