java.lang.VerifyError: (class: org/apache/jasper/c

2019-08-07 14:25发布

问题:

I'm creating an application where I'm getting the error shown below.

I'm using Tomcat 6.0 and Spring 3.0.

SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.VerifyError: (class: org/apache/jasper/compiler/JspUtil, method: <clinit> signature: ()V) Incompatible argument to function
at org.apache.jasper.JspCompilationContext.getServletClassName(JspCompilationContext.java:371)
at org.apache.jasper.JspCompilationContext.getClassFileName(JspCompilationContext.java:511)
at org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:445)
at org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:392)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:582)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
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:852)
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:636)

Please let me know if any other details are required...

**NOTE: The same application was working earlier using a Java EE server. Now I have changed it to Tomcat instead of this Java EE server.

Thanks in advance and let me know if I am missing anything.

回答1:

This indicates that you have servlet container specific libraries like jsp-api.jar in your webapp's /WEB-INF/lib. This is not right. Remove them all. Your webapp's /WEB-INF/lib should contain only the libraries which are specific to the webapp itself, not to the target server. The target server has those libraries already in its own /lib folder and they should be kept untouched and for sure not be copied/moved around.

Incorrectly copying/placing servlet container specific libraries in /WEB-INF/lib is a pretty common beginner's mistake while they are blindly looking for a solution/workaround for the JSP/Servlet-related compilation errors they got in their IDE.

See also:

  • How do I import the javax.servlet API in my Eclipse project?


回答2:

java.lang.VerifyError happens when you have compiled against a different Jar than you are using at runtime.

Tomcat might have wrong version of apache Jars (could be older/newer version) based on error class: org/apache/jasper/compiler/JspUtil. Please make sure you have correct Jars in classpath.