2013-07-17 120 views
-5

這裏是我的基於Java Struts的web應用程序和webRoot目錄的目錄結構。getting org.apache.jasper.JasperException:java.lang.NullPointerException

enter image description here

enter image description here

代碼獲得成功編譯,但是當我運行瀏覽器,它提供了異常與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) 

誰能幫助我在此,請感謝提前。

我試過戰爭文件運行外部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

提供的信息並不多。添加你的'web.xml'和'web文件夾結構',可能會幫助你解決一些問題。 –

回答

1

做一件事時,JSP被編譯成Java Servlet,因此您可以檢查代碼,看看在適當的線。 java文件是我猜測在tomcat的工作目錄中。

錯誤

org.apache.jsp.index_jsp._jspInit(index_jsp.java:22) 

這裏的線是看文件。

index_jsp.java 
0

您可能得到了版本不匹配,庫文件版本不正確,或者從早期版本中損壞/部分JSP編譯。

查看Tomcat/work目錄(C:\ Dev \ Tomcat 6.0.35 \ work \ Catalina \ localhost \ jr \ org \ apache \ jsp \ WEB_002dINF \ jsp),在我的系統&上可以看到index_jsp.java文件的源代碼。

清理Tomcat/work目錄以強制重新編譯所有JSP。

從Tomcat 6,_jspInit()的一個例子JSP的樣子:

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()); 
} 

從本質上講,這東西應該工作 - 所以幾乎可以肯定在你的配置有問題。

相關問題