Environment: MYECLIPSE+TOMCAT6+JDK6
Today, a Java Web project was built, accessing the index.jsp times with the following error:
Critical: Servlet.service () for Servlet JSP threw exception
java.lang.NullPointerException
At Org.apache.jsp.front.index_jsp._jspinit (index_jsp.java:30)
At Org.apache.jasper.runtime.HttpJspBase.init (httpjspbase.java:52)
At Org.apache.jasper.servlet.JspServletWrapper.getServlet (jspservletwrapper.java:164)
At Org.apache.jasper.servlet.JspServletWrapper.service (jspservletwrapper.java:340)
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:723)
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 Org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel ( internalresourceview.java:238)
At Org.springframework.web.servlet.view.AbstractView.render (abstractview.java:250)
At Org.springframework.web.servlet.DispatcherServlet.render (dispatcherservlet.java:1047)
At Org.springframework.web.servlet.DispatcherServlet.doDispatch (dispatcherservlet.java:817)
At Org.springframework.web.servlet.DispatcherServlet.doService (dispatcherservlet.java:719)
At org.springframework.web.servlet.FrameworkServlet.processRequest (frameworkservlet.java:644)
At Org.springframework.web.servlet.FrameworkServlet.doGet (frameworkservlet.java:549)
At Javax.servlet.http.HttpServlet.service (httpservlet.java:617)
At Javax.servlet.http.HttpServlet.service (httpservlet.java:723)
At Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:290)
At Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:206)
At org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (characterencodingfilter.java:88)
At Org.springframework.web.filter.OncePerRequestFilter.doFilter (onceperrequestfilter.java:76)
At Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:235)
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:103)
At Org.apache.catalina.core.StandardEngineValve.invoke (standardenginevalve.java:109)
At Org.apache.catalina.connector.CoyoteAdapter.service (coyoteadapter.java:293)
At org.apache.coyote.http11.Http11AprProcessor.process (http11aprprocessor.java:879)
At org.apache.coyote.http11.http11aprprotocol$http11connectionhandler.process (http11aprprotocol.java:617)
At Org.apache.tomcat.util.net.aprendpoint$worker.run (aprendpoint.java:1778)
At Java.lang.Thread.run (thread.java:662)
Baidu has a half-day, are said to be the project inside the jar package and Tomcat Lib directory of the Jar package conflict, check the Lib directory of the project, found that there are indeed two packet conflicts, one is Jsp-api.jar, the other is Servlet-api.jar. The solution is to remove the two packages from the project Lib, and then right- click on the project->build path, Configure Build path, Libraries, add External JAR will Add the required jar package, reboot tomcat OK
Original: http://zhouhaitao.iteye.com/blog/1164736
Java Web project Error java.lang.NullPointerException at Org.apache.jsp.front.index_jsp._jspinit (index_jsp.java:30)