AnnotationProcessor转换错误
HTTP Status 500 - java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor
type Exception report
message java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor
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.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:542)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
com.assoft.filter.SecurityFilter.doFilter(SecurityFilter.java:108)
root cause
java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor
org.apache.jsp.index_jsp._jspInit(index_jsp.java:23)
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:321)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
com.assoft.filter.SecurityFilter.doFilter(SecurityFilter.java:108)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.47 logs.
Apache Tomcat/6.0.47
因为Tomcat中catalina.jar和jasper.jar都有AnnotationProcessor接口,所以运行时,就出错了:Java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor
。
因此在tomcat中的context.xml文件中添加<Loader delegate="true" />
就可以了。
Loader对象可出现在Context中以控制Java类的加载。虽然可以改变loadet类,不过一般不会这样做,所以在下面的属性中,我们们列出了标准的属性和“一般”类加载器所接受的属性。
属性:
className
含义:org.apache.catalina.Loader
实现类名、默认值:org.apache.catalina.loader.WebappClassLoader
属性:
delegate
含义: True代表使用正式的Java代理模式(先询问父类的加载器);false代表先在Web应用程序中寻找。警告:如果不知道如何处理,则不要改变这一属性值、默认值:FALSE属性:
loaderClass
含义: 类加载器、默认值:org.apache.catalina.loader.WebappClassLoader
属性:
reloadable
含义: 与Context下的意义相同。这时的值会改写Context中的值、默认值:FALSE属性:
workDir
含义: 存放临时文件的目录、默认值:CATALINA_BASE下的临时目录(如果不显示设定CATALINA_TOME的值,则是CATALINA_BASE)