Tomcat 6中的org.apache.jsp.page_jsp._jspInit中的java.lang.NullPointerException,但在Tomcat 7中有效

时间:2012-08-30 14:37:37

标签: java jsp tomcat servlets

在我的servlet中我做了:

request.getRequestDispatcher("/page.jsp").forward(request,response);

我在Tomcat 6上获得了以下NullPointerException,但它在Tomcat 7中有效。

SEVERE: Servlet.service() for servlet jsp threw exception java.lang.NullPointerException
    at org.apache.jsp.page_jsp._jspInit(page_jsp.java:23)
    at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
    at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    at com.dotvocal.poa.vocal.main.servlet.LoadCompany.execute(MyServlet.java:100)
    at com.dotvocal.poa.vocal.main.servlet.LoadCompany.doGet(MyServlet.java:60)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)

我也尝试了以下内容:

request.getRequestDispatcher("http://localhost:8080/myapp/page.jsp").forward(request,response);

但它没有解决问题。

2 个答案:

答案 0 :(得分:2)

  

org.apache.jsp.page_jsp._jspInit(page_jsp.java:23)中的java.lang.NullPointerException

您的网络应用jsp-api.jar/WEB-INF/libJDK/lib中有特定于servletcontainer的JSP库,例如JDK/lib/ext

删除。他们根本不属于那里。 servletcontainer本身已经附带了这些库。基于问题症状,你在webapp中的那个源自Tomcat 7,因此当你将它部署到不同的servletcontainer make /版本(例如Tomcat 6)时,你的webapp将无法工作,因为它会与servletcontainer自己发生冲突库。

在webapp的/WEB-INF/lib中错误地放置特定于servlet容器的库是错误尝试修复IDE项目中的Servlet API编译错误的经典启动器错误。您应该在IDE项目中将servletcontainer引用为“目标运行时”。

另见:

答案 1 :(得分:0)

我使用JBoss 4.3时遇到了同样的错误,我的解决方案是从我的JBoss环境中删除日志,工作和tmp文件夹。