tomcat發布web項目JSP頁面開啟報null 指標異常解決方案。

來源:互聯網
上載者:User
訪問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
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.