9

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

jmruc
  • 5,714
  • 3
  • 22
  • 41
Rishabh
  • 338
  • 1
  • 3
  • 17
  • 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 '12 at 07: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 '12 at 09:13

3 Answers3

11

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?

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 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 '12 at 07:09
  • Thanks BalusC, cleaning up the jars in /lib solved the problem! – Rishabh Oct 18 '12 at 16:04
  • 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 '14 at 14:11
  • @Josh: Just follow the link in my answer. – BalusC Jun 12 '14 at 14:20
  • 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 '16 at 15:10
0

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

Herupkhart
  • 499
  • 4
  • 23
  • Cleaning the cache in eclipse dosent solve the problem. I think problem must be because of the missing/inconsistent jars – Rishabh Oct 10 '12 at 09:22
0

Remove the following from lib.

  1. Check for same jar with different versions
  2. All catalina related jars
  3. el-api.jar
  4. jsp-api.jar

This will definitely work.

Ramvignesh
  • 210
  • 6
  • 16