訪問JSP頁面直接報:
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.NullPointerExceptionorg.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)org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)javax.servlet.http.HttpServlet.service(HttpServlet.java:617)javax.servlet.http.HttpServlet.service(HttpServlet.java:717)org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause
java.lang.NullPointerExceptionorg.apache.jsp.WEB_002dINF.pages.imagecheck.test_jsp._jspInit(test_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.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)javax.servlet.http.HttpServlet.service(HttpServlet.java:617)javax.servlet.http.HttpServlet.service(HttpServlet.java:717)org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)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.
後面百度查了原因,是項目lib下面的jsp-api.jar和tomcat 下的jsp-api.jar有衝突導致的。因為我項目裡用到了一個user library裡包含了jsp-api.jar 和servlet-api.jar兩個包,然後通過myeclips發布的時候將這兩個包複製到webroot/lib下去了,而tomcat的lib下面本來就有這兩個包,導致了衝突,這就是這個錯誤產生的主要原因。
解決方案是,編輯自訂user library,將user library設定為 system library,這樣在通過myeclips發布時就不會自動拷貝這兩個JAR包。
或者通過在tomcat_home/conf/catalina/下面加一個設定檔指定webroot來發布項目,避免不必要的自動拷貝.
以前都是用後一種方式發布的項目,今天突然測試一個代碼,然後偷懶用myeclipse上的發布按鈕發布到tomcat的webapps目錄下的發布方式。結果就出現了今天的這個問題,還奇怪的怎麼好好的代碼就不好用了,整了好幾個小時,各種百思不得其解啊。整半天原來是JAR包衝突導致的。
spring mvc架子搭好了,可以訪問jsp了,淚流滿面啊。碼代碼去- -#
Apache Tomcat/6.0.35