2013年5月27日 星期一

[分享]jspInit中發生java.lang.NullPointerException錯誤

在Tomcat中部署war檔後,開啟網頁,會出現下面錯誤:

HTTP Status 500 -


type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.NullPointerException
 org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:538)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 ....SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:122)
 ...
 org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 ...
root cause
java.lang.NullPointerException
 ...._jspInit(Login_jsp.java:22)
 org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
 org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:164)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 ...
 org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 ....
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.

主要原因是在專案中的WEB-INF/lib下,存在著jsp-api.jar,其版本和Tomcat的版本衝到,將其移除後,重新部署,問題即可解決。

沒有留言: