一、异常怎么看,chrom浏览器功能很强大
看以看出是如下异常
<html><head><title>Apache Tomcat/6.0.36 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - Servlet execution threw an exception</h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>Servlet execution threw an exception</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>javax.servlet.ServletException: Servlet execution threw an exception
org.sitemesh.webapp.contentfilter.ContentBufferingFilter.bufferAndPostProcess(ContentBufferingFilter.java:169)
org.sitemesh.webapp.contentfilter.ContentBufferingFilter.doFilter(ContentBufferingFilter.java:126)
org.sitemesh.config.ConfigurableSiteMeshFilter.doFilter(ConfigurableSiteMeshFilter.java:163)
com.aebiz.pub.util.filters.MyConfigurableSiteMeshFilter.doFilter(MyConfigurableSiteMeshFilter.java:81)
com.aebiz.pub.util.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:142)
</pre></p><p><b>root cause</b> <pre>java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
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)
com.aebiz.plugin.jcaptcha.DrawRandNumber.drawRandNumber(DrawRandNumber.java:61)
com.aebiz.plugin.jcaptcha.ImageCaptchaServlet.doGet(ImageCaptchaServlet.java:36)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.sitemesh.webapp.contentfilter.ContentBufferingFilter.bufferAndPostProcess(ContentBufferingFilter.java:169)
org.sitemesh.webapp.contentfilter.ContentBufferingFilter.doFilter(ContentBufferingFilter.java:126)
org.sitemesh.config.ConfigurableSiteMeshFilter.doFilter(ConfigurableSiteMeshFilter.java:163)
com.aebiz.pub.util.filters.MyConfigurableSiteMeshFilter.doFilter(MyConfigurableSiteMeshFilter.java:81)
com.aebiz.pub.util.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:142)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/6.0.36 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.36</h3></body></html>
二、问题解决,利用如下链接下的解决方案
网站验证码突然无法显示,并报如下错误。
Caused by: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
Caused by: java.lang.InternalError: Can't connect to X11 window server using 'localhost:10.0' as the value of the DISPLAY variable.
网上搜索了一下,在catalina.sh里加上一句“-Djava.awt.headless=true \”,问题解决。
经查,出现这种情况一般就是启动tomcat的用户无法访问Xserver,包括Xserver没有启动或者没有权限访问.
以下为转贴:
1.什么是Headless mode?
Headless模式是系统的一种配置模式。在该模式下,系统缺少了显示设备、键盘或鼠标。
2.何时使用和headless mode?
Headless模式虽然不是我们愿意见到的,但事实上我们却常常需要在该模式下工作,尤其是服务器端程序开发者。因为服务器(如提供Web服务的主机)往往可能缺少前述设备,但又需要使用他们提供的功能,生成相应的数据,以提供给客户端(如浏览器所在的配有相关的显示设备、键盘和鼠标的主机)。
3.如何使用和Headless mode?
一般是在程序开始激活headless模式,告诉程序,现在你要工作在Headless mode下,就不要指望硬件帮忙了,你得自力更生,依靠系统的计算能力模拟出这些特性来:
System.setProperty("java.awt.headless","true");
修改${TOMCAT_HOME}/bin/catalina.sh或${TOMCAT_HOME}/bin/catalina.bat文件:
在所有类似以下代码:
"$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
-Djava.security.manager \
-Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \
-Dcatalina.base="$CATALINA_BASE" \
-Dcatalina.home="$CATALINA_HOME" \
-Djava.io.tmpdir="$CATALINA_TMPDIR" \
在尾部加上一句:
-Djava.awt.headless=true \
修改后内容如下:
exec "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
-Dcatalina.base="$CATALINA_BASE" \
-Dcatalina.home="$CATALINA_HOME" \
-Djava.io.tmpdir="$CATALINA_TMPDIR" \
-Djava.awt.headless=true \
以tomcat6.0为例,总共有七处这样的地方,修改好后即可。
http://my.oschina.net/xiangtao/blog/28441
http://stackoverflow.com/questions/29084674/cannot-run-intellij-noclassdeffounderror-could-not-initialize-class-sun-awt-x