java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor 访问jsp报错 过滤器异常
07:16:33,911 ERROR CharsetEncoding:38 - java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor org.apache.jasper.JasperException: java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.****.CharsetEncoding.doFilter(CharsetEncoding.java:30) 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:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
解决方案1:
当项目中引用tomcat目录下面的lib下面的catalina.jar的时候,用myeclipse将项目部署到tomcat下面的时候,会将catalina.jar包加到项目的web-inf下面的lib文件夹下面,这样这个包就会和tomcat下面的lib下面的catalina.jar包冲突会报java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor错误,解决方法是将项目部署到tomcat下面后,将项目的web-inf/lib下面的catalina.jar删掉,然后在重启tomcat,ok。
方案2:
修改了tomcat里的context.xml文件,在context 元素下添加
<Context>
<Loader delegate="true" />
本文转自yjflinchong 51CTO博客,原文链接:http://blog.51cto.com/yjflinchong/1164951,如需转载请自行联系原作者