Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have a java web application. I have set up this new project and getting the following exception when I run a jsp,

Oct 10, 2012 3:01:49 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor
    at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:151)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    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 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:127)
    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:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:619)
Oct 10, 2012 3:01:57 AM org.apache.catalina.loader.WebappClassLoader modified
INFO:     Additional JARs have been added : 'activation-1.1.jar'
Oct 10, 2012 3:01:57 AM org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
Oct 10, 2012 3:01:57 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/AutoUpgrade] registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Oct 10, 2012 3:01:57 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/AutoUpgrade] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.

I have tried clean and building the project many times, getting the latest service-api.jar, my lib is very extensive and I cannot figure out whether there is any inconsistencies between any jar that is causing this error. I am running the project on Apache Tomcat 6 on jdk 1.6 (my project needs to run on 1.6). I have tried googling this exception, but didnt get any post relevant to my problem. The relevant questions on stackoverflow talk about NullPointerException.

I think the problem must be with my library, but I can not point to root cause.

Thanks

Is the problem with a specific JSP, or with all JSPs? How do you manige dependencies - maven/ivy/gradle or just copying jars by hand? You could look at your dependencies list, to see if any tomcat library is included as project dependency - that will most likely to be the problem. – jmruc Oct 10, 2012 at 7:35 The problem is with all jsps. I have copied all jar files by hand into my projects lib folder. Will check the dependencies in my tomcat library and let you know – Rishabh Oct 10, 2012 at 9:13

This can happen when you have Tomcat-specific JAR files in your webapp's /WEB-INF/lib. This is not right. You should remove all servletcontainer-specific JAR files from there. They do not belong there at all. They are supposed to be already provided by the servletcontainer itself. The /WEB-INF/lib should only contain libraries specific to the webapp itself which are not provided by the servletcontainer.

If you have placed them there as a result of an unthoughtful attempt to fix compilation errors, then please carefully read this answer how to solve it the right way: How do I import the javax.servlet API in my Eclipse project?

Sorry for the late reply. I was caught up in other projects. Your answer makes complete sense and I remember using servletcontainer-specific JAR in my WEB-INF/lib. Will remove such conflicting JAR's and let you know how things work! Thanks, – Rishabh Oct 15, 2012 at 7:09 Hm, well my problem is I need access to org.apache.catalina, and I'm not sure how to do that without adding it as a resource. Any ideas? – Drazen Bjelovuk Jun 12, 2014 at 14:11 What about when the JARs are indirectly included by a pom.xml dependency? Or when you need a newer version of a JAR than the one provided by the servlet container? – user1156544 Jun 28, 2016 at 15:10

If cleaning your project didn't help, perhaps you need to clear your cache.

The Netbeans cache is located somewhere...
C:\Documents and Settings\myself.netbeans\7.0\var\cache

Cleaning the cache in eclipse dosent solve the problem. I think problem must be because of the missing/inconsistent jars – Rishabh Oct 10, 2012 at 9:22

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.