You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mitch Gitman <mg...@gmail.com> on 2006/05/28 03:40:45 UTC

JasperException not passed to error page

I have a JSP with an invalid call to a JSTL function. If I go to access this
page, Tomcat 5.5.16 spits out its own error page. Excerpt follows:
HTTP Status 500 -
...
description The server encountered an internal error () that prevented it
from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP:
/WEB-INF/jsp/overview/overview.jsp:185
...
Stacktrace:
   org.apache.jasper.servlet.JspServletWrapper.handleJspException(
JspServletWrapper.java:504)
   org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java:375)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
...

Likewise, I see a descriptive exception output in stdout.log:
12:15:33,966 ERROR [jsp]:704 - Servlet.service() for servlet jsp threw
exception
javax.servlet.jsp.el.ELException: Attempt to coerce a value of type "
java.util.ArrayList" to type "[Ljava.lang.String;"
   at org.apache.commons.el.Logger.logError(Logger.java:481)
   at org.apache.commons.el.Logger.logError(Logger.java:498)
   at org.apache.commons.el.Logger.logError(Logger.java:566)
...

Fine. However, this naked Tomcat error page is obviously not the kind of
page I want to be presenting in a production application. So I add the
following two attributes to the page directive at the top of the JSP:
isErrorPage="false" errorPage="WEB-INF/jsp/error.jsp"

What happens next is the error page gets displayed, as expected, with a 404
status code. But there's no JasperException, or any exception, to be found:
·    ${pageContext.errorData.throwable} is null
·    ${pageContext.exception} is null

Likewise, there is no evidence of the JasperException in the logs. I tried
lowering the Tomcat log level, to no avail. Incidentally, my application
error page does successfully display exception information for other types
of exceptions.

So why does the error page fail to pick up the JasperException even though
it gets invoked on the JasperException? It seems odd that the developer
should be presented with an error page that gives no hint of the error and
that their only recourse is to remember to remove the errorPage declaration
from the offending JSP.

By the way, in my web.xml, I have (and apparently need) the following:
    <error-page>
        <error-code>404</error-code>
        <location>/WEB-INF/jsp/error.jsp</location>
    </error-page>

    <error-page>
        <error-code>500</error-code>
        <location>/WEB-INF/jsp/error.jsp</location>
    </error-page>