java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor 訪問jsp報錯-過濾器報錯 – JAVA編程語言程序開發技術文章

[java] 
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

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。