这是我的基于Java Struts的Web应用程序和webRoot目录的目录结构。
代码已成功编译,但当我将其运行到浏览器时,它会给出HTTP状态500的异常:
org.apache.jasper.JasperException: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.NullPointerException
org.apache.jsp.index_jsp._jspInit(index_jsp.java:22)
org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
请允许任何人帮助我,请提前致谢。
我尝试使用war文件来运行外部tomcat-7但显示相同的错误,也发现了这个org.apache.jasper.JasperException: java.lang.NullPointerException但对我没有帮助。
这是web.xml
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Ilex Reports</display-name>
<description>Report Server</description>
<servlet>
<servlet-name>rpt</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>host</param-name>
<param-value>localhost</param-value>
</init-param>
<init-param>
<param-name>port</param-name>
<param-value>80</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>rpt</servlet-name>
<url-pattern>*.xo</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
<!-- Custom Tag Library Descriptors -->
<taglib>
<taglib-uri>http://jakarta.apache.org/tomcat/fb-taglib</taglib-uri>
<taglib-location>/WEB-INF/tld/Element.tld</taglib-location>
</taglib>
<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/tags/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-logic</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-nested</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-tiles</taglib-uri>
<taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location>
</taglib>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
</web-app>
答案 0 :(得分:1)
做一件事,jsps被编译成java servlet,所以你可以检查代码并查看相应的行。我想是在tomcat的工作目录中的java文件。
错误行
org.apache.jsp.index_jsp._jspInit(index_jsp.java:22)
这是要查看的文件。
index_jsp.java
答案 1 :(得分:0)
您可能会遇到版本不匹配,库版本不正确或者早期的损坏/部分JSP编译。
在我的系统&amp;上查看Tomcat /工作目录(C:\ Dev \ Tomcat 6.0.35 \ work \ Catalina \ localhost \ jr \ org \ apache \ jsp \ WEB_002dINF \ jsp)。你可以看到index_jsp.java文件的源代码。
清理Tomcat / work目录以强制重新编译所有JSP。
从Tomcat 6开始,示例JSP中的_jspInit()看起来像:
public void _jspInit() {
_005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005fnobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_005fjspx_005ftagPool_005fc_005furl_0026_005fvalue_005fnobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005fescapeXml_005fnobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
_jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
}
基本上,这些东西应该有效 - 所以你的配置几乎肯定存在问题。