java.lang.ClassCastException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I tried to reconfigure Spring-DM 1.2.0 M2 to use Tomcat 6.0.16 instead of Tomcat 5.5. I used the catalina 6.0.16 and jasper 6.0.16 jars from the temporary Spring-DM repo and it's dependencies and starting up the osgi stack works well. But I run into a classcast exeception as soon as I open my application in the browser. java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:146) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 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:175) 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:844) 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(Thread.java:619) it seems that the problem is this: Bundle org.springframework.osgi.catalina.osgi (catalina.osgi-6.0.16-20080321.182649-3.jar): - has org.apache.AnnotationProcessor - DOESN'T export the package org.apache - has org.apache.catalina.util.DefaultAnnotationProcessor that implements org.apache.AnnotationProcessor (the one from the catalina bunlde) Bundle org.springframework.osgi.jasper.osgi (jasper.osgi-6.0.16-20080624.095828-1): - has ALSO org.apache.AnnotationProcessor (a second one) - DOES export the package org.apache - Wants to cast org.apache.catalina.util.DefaultAnnotationProcessor to org.apache.AnnotationProcessor (the exported one from the jasper bundle) -> ClassCastException As you can see this can't work. IMHO there should only be one org.apache.AnnotationProcessor. In fact this actually is of course more an error of tomcat 6 that hasn't been noticed because until now there was only one classpath. I also opened an issue for tomcat 6. See: https://issues.apache.org/bugzilla/show_bug.cgi?id=46344
    via by Roger Villars,
  • I tried to reconfigure Spring-DM 1.2.0 M2 to use Tomcat 6.0.16 instead of Tomcat 5.5. I used the catalina 6.0.16 and jasper 6.0.16 jars from the temporary Spring-DM repo and it's dependencies and starting up the osgi stack works well. But I run into a classcast exeception as soon as I open my application in the browser. java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:146) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 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:175) 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:844) 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(Thread.java:619) it seems that the problem is this: Bundle org.springframework.osgi.catalina.osgi (catalina.osgi-6.0.16-20080321.182649-3.jar): - has org.apache.AnnotationProcessor - DOESN'T export the package org.apache - has org.apache.catalina.util.DefaultAnnotationProcessor that implements org.apache.AnnotationProcessor (the one from the catalina bunlde) Bundle org.springframework.osgi.jasper.osgi (jasper.osgi-6.0.16-20080624.095828-1): - has ALSO org.apache.AnnotationProcessor (a second one) - DOES export the package org.apache - Wants to cast org.apache.catalina.util.DefaultAnnotationProcessor to org.apache.AnnotationProcessor (the exported one from the jasper bundle) -> ClassCastException As you can see this can't work. IMHO there should only be one org.apache.AnnotationProcessor. In fact this actually is of course more an error of tomcat 6 that hasn't been noticed because until now there was only one classpath. I also opened an issue for tomcat 6. See: https://issues.apache.org/bugzilla/show_bug.cgi?id=46344
    via by Roger Villars,
  • Servlet.service() throws ClassCastException
    via Stack Overflow by Rishabh
    ,
  • Spring MVC -- java.lang.ClassCastException
    via Stack Overflow by Frank
    ,
  • Broken sample
    via by Gabe Wachob,
    • java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:146) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 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:175) 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:844) 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(Thread.java:619)
    No Bugmate found.