zoukankan      html  css  js  c++  java
  • java.lang.InternalError: Can't connect to X11 window server using 'xx.xx.xx.xx:0.0' as the value of the DISPLAY variable.

    今天在做JSP图片验证码的时候,在windows下面显示正常,部署到linux下就无法正常显示,报异常如下:

    org.apache.jasper.JasperException: An exception occurred processing JSP page /image.jsp at line 21

    18: response.setDateHeader("Expires", 0);
    19: int width=60, height=20;
    20: BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    21: Graphics g = image.getGraphics();
    22: Random random = new Random();
    23: g.setColor(getRandColor(200,250));
    24: g.fillRect(0, 0, width, height);


    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


    root cause

    javax.servlet.ServletException: java.lang.InternalError: Can't connect to X11 window server using 'xx.xx.xx.xx:0.0' as the value of the DISPLAY variable.
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:852)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
    org.apache.jsp.image_jsp._jspService(image_jsp.java:114)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


    root cause

    java.lang.InternalError: Can't connect to X11 window server using 'xx.xx.xx.xx:0.0' as the value of the DISPLAY variable.
    sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
    sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52)
    sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155)
    java.security.AccessController.doPrivileged(Native Method)
    sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131)
    java.lang.Class.forName0(Native Method)
    java.lang.Class.forName(Class.java:169)
    java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
    java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1135)
    java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1125)
    org.apache.jsp.image_jsp._jspService(image_jsp.java:81)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.

    解决方法:

    修改 tomcat/bin/catalina.sh 文件,添加 一行    JAVA_OPTS=-Djava.awt.headless=true 

    重启tomcat后,问题解决。

  • 相关阅读:
    redis 学习(17) -- RDB
    51单片机程序技巧
    无效设备解决办法
    210板子启动笔记
    RFID读卡器设置卡
    Socket简介
    /etc/hosts.conf
    TVP5150摄像头
    maven小试牛刀
    2014图灵技术图书最受欢迎TOP15
  • 原文地址:https://www.cnblogs.com/acmy/p/2518407.html
Copyright © 2011-2022 走看看