问题描述
严重: Servlet.service() for servlet jsp threw exceptionjava.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessorat org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:144)at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)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:228)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)at java.lang.Thread.run(Thread.java:619)
解决方案
出错原因是类型转换出错ClassCastException,网上搜了下,造成这个异常是因为Tomcat中catalina.jar和jasper.jar都有AnnotationProcessor接口,所以运行时,就出错了:java.lang.ClassCastException:org.apache.catalina.util.DefaultAnnotationProcessorXXXX,......其实就是项目里引入的jar包放多了,有些没必要的。。。。修改了tomcat里的context.xml文件,在context 元素下添加<Loader delegate="true" /> 即可http://blog.csdn.net/xiaxiaorui2003/article/details/5735328
解决方案二:
哥哥,你配置环境变量了吗?配置一下就好了
解决方案三:
修改了tomcat里的context.xml文件,在context 元素下添加 <Loader delegate="true" /> 看看tomcat的官网的说法:http://tomcat.apache.org/tomcat-6.0-doc/config/loader.html
解决方案四:
tomcat里的context.xml文件,在context 元素下添加 <Loader delegate="true" /> 设置优先加载,就不会引起冲突
解决方案五:
分析异常信息:1、找出出错原因ClassCastException->类型转换出错,API文档里面也能查到,你可以下载一个中文的文档。2、找到出错的代码,异常信息里面也有,而且这句代码应该是你自己写的,你仔细看看就能找到。以后有异常也基本可以这样分析 。。
解决方案六:
类型不匹配。看看这个:http://sanfeng-chow.iteye.com/blog/1007104
解决方案七:
不是说的很清楚了吗?运行什么报错?