Wednesday, 6 July 2011

Tomcat JSP Compilation Exception

I was recently porting a simple web-app from Weblogic to Tomcat 7. Everything seemed fine, and it all deployed correctly. However, when I ran a simple test, by requesting the first page, I got the following exception:
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 38 in the generated java file
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

 at org.apache.jasper.compiler.DefaultErrorHandler.javacError(
 at org.apache.jasper.compiler.ErrorDispatcher.javacError(
 at org.apache.jasper.compiler.JDTCompiler.generateClass(
 at org.apache.jasper.compiler.Compiler.compile(
 at org.apache.jasper.compiler.Compiler.compile(
 at org.apache.jasper.compiler.Compiler.compile(
 at org.apache.jasper.JspCompilationContext.compile(
 at org.apache.jasper.servlet.JspServletWrapper.service(
The problem was caused by a couple of mis-matched libraries. For Weblogic, my Mavern POM file had to contain the following JAR references:
It turns out that Tomcat has its own copies of these JAR files in its lib directory and hence the solution is to remove these dependencies from your POM and to use Tomcat’s versions. I’m using the lastest versions available from Mavern Central, so are these out of date, or is Tomcat using obsolete JARs?

No comments: