You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Roger Roger <rx...@gmail.com> on 2007/06/05 14:23:00 UTC

HTTP 500 when using custom error pages in Tomcat 6.0

Hi there,

Recently we upgraded to Tomcat 6.0. Suddenly the custom errorpages don't
work anymore. For this test I created a simple jsp-page with <%=x%> in it
without declaring that x so it would result in an error. I would like to
know how I can get the customized page (error.jsp) back.

#################################
test.jsp
#################################
<%@ page errorPage="error.jsp" %>

<html>
<body>
<h1>Error test page</h1>
<%=x%>
</body>
</html>

#################################
error.jsp
#################################

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
">
<html>
<body>
      <h1>Error message</h1>
      <p>Something went wrong!</p>
      <div><%= exception.getMessage () %></div>
</body>
</html>


#################################
HTTP Status 500 -
#################################

type Exception report

message

description The server encountered an internal error () that prevented it
from fulfilling this request.

exception

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

An error occurred at line: 6 in the jsp file: /error/errormessage.jsp
x cannot be resolved
3: <html>
4: <body>
5: <h1>Error test page</h1>
6: <%=x%>
7: </body>
8: </html>


Stacktrace:
      org.apache.jasper.compiler.DefaultErrorHandler.javacError(
DefaultErrorHandler.java:92)
      org.apache.jasper.compiler.ErrorDispatcher.javacError(
ErrorDispatcher.java:330)
      org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java
:423)
      org.apache.jasper.compiler.Compiler.compile (Compiler.java:308)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
      org.apache.jasper.JspCompilationContext.compile(
JspCompilationContext.java:566)
      org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java:317)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
:320)
      org.apache.jasper.servlet.JspServlet.service (JspServlet.java:266)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

After repeated refreshes, I sometimes get the following error:

#################################
HTTP Status 500 -
#################################

type Exception report

message

description The server encountered an internal error () that prevented it
from fulfilling this request.

exception

org.apache.jasper.JasperException : org.apache.jasper.JasperException:
Unable to load class for JSP
      org.apache.jasper.servlet.JspServletWrapper.getServlet(
JspServletWrapper.java:156)
      org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java :329)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
:320)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
      javax.servlet.http.HttpServlet.service(HttpServlet.java :803)

root cause

org.apache.jasper.JasperException: Unable to load class for JSP
      org.apache.jasper.JspCompilationContext.load(
JspCompilationContext.java:600)
      org.apache.jasper.servlet.JspServletWrapper.getServlet (
JspServletWrapper.java:144)
      org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java:329)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
:320)
      org.apache.jasper.servlet.JspServlet.service (JspServlet.java:266)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

java.lang.ClassNotFoundException: org.apache.jsp.error.errormessage_jsp
      java.net.URLClassLoader$1.run (URLClassLoader.java:200)
      java.security.AccessController.doPrivileged(Native Method)
      java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134)
      org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
      org.apache.jasper.JspCompilationContext.load(
JspCompilationContext.java:598)
      org.apache.jasper.servlet.JspServletWrapper.getServlet (
JspServletWrapper.java:144)
      org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java:329)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
:320)
      org.apache.jasper.servlet.JspServlet.service (JspServlet.java:266)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

Thanks for your input!

Roger

Re: HTTP 500 when using custom error pages in Tomcat 6.0

Posted by Rashmi Rubdi <ra...@gmail.com>.
On 6/5/07, Roger Roger <rx...@gmail.com> wrote:
> Hi there,
>
> Recently we upgraded to Tomcat 6.0. Suddenly the custom errorpages don't
> work anymore.

It works, when I try the example you've shown in your first post.

A few things you may want to check:

1) errorPage="error.jsp"   , is error.jsp relative to test.jsp ?

Since the above is a ~page relative~ path, both test.jsp and error.jsp
should be in the same folder , otherwis error.jsp will not be found.

A better approach would be to make errorPage a ~context~ relative path
, something like errorPage="/errors/error.jsp"  , this way error.jsp
will be visible to any page in your app when you use that path.

2) Is the web.xml configured correctly, is the path of error.jsp in
web.xml correct? Again, it should be context relative.



-Rashmi

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org