eclipse+tomcat無法訪問jsp異常
org.apache.jasper.JasperException: java.lang.ClassCastException: org.apache.catalina.core.DefaultInstanceManager cannot be cast to org.apache.tomcat.InstanceManager
頁面錯誤:
Html程式碼- 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.ClassCastException: org.apache.catalina.core.DefaultInstanceManager cannot be cast to org.apache.tomcat.InstanceManager
- org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:168)
-
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356)
- org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
- org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
- javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
- root cause
-
java.lang.ClassCastException: org.apache.catalina.core.DefaultInstanceManager cannot be cast to org.apache.tomcat.InstanceManager
- org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(InstanceManagerFactory.java:32)
- org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:161)
- org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356)
- org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
- org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
- javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
- note The full stack trace of the root cause is available in the Apache Tomcat/7.0.11 logs.
- Apache Tomcat/7.0.11
Java控制檯錯誤:
Java程式碼- 嚴重: Servlet.service() for servlet [jsp] in context with path [/servlet3] threw exception [java.lang.ClassCastException: org.apache.catalina.core.DefaultInstanceManager cannot be cast to org.apache.tomcat.InstanceManager] with root cause
- java.lang.ClassCastException: org.apache.catalina.core.DefaultInstanceManager cannot be cast to org.apache.tomcat.InstanceManager
- at org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(InstanceManagerFactory.java:32)
- at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:161)
- at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356)
- at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
- at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
- at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
- at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
- at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
- at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
- at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
- at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
- at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
- at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
- at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
- at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
- at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
- at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:284)
- at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:322)
- at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1714)
- at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
- at java.lang.Thread.run(Thread.java:619)
原因:
當專案中引用tomcat目錄下面的lib下面的catalina.jar的時候,用myeclipse將專案部署到tomcat下面的時候,會將 catalina.jar包加到專案的web-inf下面的lib資料夾下面,這樣這個包就會和tomcat下面的lib下面的catalina.jar 包衝突會報java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor錯誤
解決方法:
修改了tomcat裡的context.xml檔案,
在context 元素下新增<Loader delegate="true" />
如下面所示:
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<!-- Uncomment this to enable Comet connection tacking (provides events
on session expiration as well as webapp lifecycle) -->
<!--
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->
<Loader delegate="true" />
</Context>
網上還有另一種解決方法(這種方法我在web-inf/lib下一直沒找到catalina.jar):
將專案部署到tomcat下面後,將專案的web-inf/lib下面的catalina.jar刪掉,然後在重啟tomcat。
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
轉載自:http://fanshuyao.iteye.com/blog/1688314