File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Compile errors when accessing *.jsp files. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Compile errors when accessing *.jsp files." Watch "Compile errors when accessing *.jsp files." New topic

Compile errors when accessing *.jsp files.

Henry Dunn

Joined: Feb 16, 2004
Posts: 4
Hello everyone,
I am running Tomcat version 5.0.25 on a Redhat linux platform with jdk v.1.4.2.
I have been having all sorts of problems trying to setup a web application, so I started from the very basics.
I created a jsp file (with no java code/jsp tags )in the webapps/ROOT directory, and tried to access it over the web ( localhost:8080/test.jsp ) and I get this error:

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Compiling 1 source file
[javac] /usr/local/tomcat/work/Catalina/localhost/_/org/apache/jsp/ handlePageException(java.lang.Exception) in javax.servlet.jsp.PageContext cannot be applied to (java.lang.Throwable)
[javac] if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
[javac] ^
[javac] 1 error

However, I am able to access all the example jsps and servlets over the web.
I think that this is because the examples are precompiled and premapped in the corresponding web.xml files.
Please how can I resolve this issue? Thanks.

Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

do you have JAVA_HOME set (and exported)?
is the jdk really a jdk, and not just a jre ?
Henry Dunn

Joined: Feb 16, 2004
Posts: 4
Yes, I am using jdk 1.4.2 and I have the JAVA_HOME variable set to the right path. I am able to access the precompiled jsps,just not able to compile new ones.
From the error message, it seems that the compiler is being accessed but something is syntactically wrong with the srcfile for the jsp file.
matthew mckennirey

Joined: Jul 15, 2004
Posts: 1
this may be a CLASSPATH issue. Tomcat 5.0 expects to use the javax.servlet.jsp.PageContext class from a jar called servlet-api.jar in the /common/lib folder. This class includes a handlePageException(t) method that takes a throwable, which is the way Tomcat 5.0 generates the java code from the jsp page. Older jars from other sources include a javax.servlet.jsp.PageContext class that only has a handlePageException(e) mthod that takes an exception - this used to be the way Tomcat created the java code.

Your error appears to be that Tomcat 5.0 is generating java code that expects the handlePageException(t) method, but an older jar is in the way with a javax.servlet.jsp.PageContext class that only has the handlePageException(e) method.

Check the CLASSPATH and make sure the runtime CLASSPATH does not include the older javax.servlet.jsp.PageContext class, you may be including this in the CLASSPATH with your application.
I agree. Here's the link:
subject: Compile errors when accessing *.jsp files.
It's not a secret anymore!