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
注意:本文归作者所有,未经作者允许,不得转载