Bug 12978 - Tomcat doesn't pick up error pages.
Summary: Tomcat doesn't pick up error pages.
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 4
Classification: Unclassified
Component: Connector:Webapp (show other bugs)
Version: 4.1.12
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-24 22:03 UTC by Matt Raible
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
o.a.c.v.ErrorDispatcherValve patch (629 bytes, patch)
2002-09-27 18:30 UTC, John Trollinger
Details | Diff
o.a.c.v.ErrorDispatcherValve newer patch (910 bytes, patch)
2002-09-27 18:42 UTC, John Trollinger
Details | Diff
o.a.c.v.ErrorDispatcherValve even newer.. one of those days.... (1.09 KB, patch)
2002-09-27 18:47 UTC, John Trollinger
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Raible 2002-09-24 22:03:09 UTC
I have the following in web.xml:

    <error-page>
        <error-code>500</error-code>
        <location>/errorPage.jsp</location>
    </error-page>
    <error-page>
        <exception-type>javax.servlet.ServletException</exception-type>
        <location>/errorPage.jsp</location>
    </error-page>

However, I keep getting stacktraces instead of my error page.
Comment 1 Sean Reilly 2002-09-24 22:24:44 UTC
This seems to be the same thing that is happening in Bug #11091.
I don't know of a solution, but I do have a potential workaround that you could 
try:  If you change the exception-type parameter to java.lang.Throwable or 
java.lang.Exception, you should see your custom error page again.
Comment 2 Matt Raible 2002-09-24 22:58:21 UTC
So something was "broken" b/w 4.0.4 and 4.1.x?  I'm trying to migrate an 
application from 4.0.4 - where everything works fine.
Comment 3 John Trollinger 2002-09-27 18:30:56 UTC
Created attachment 3270 [details]
o.a.c.v.ErrorDispatcherValve patch
Comment 4 John Trollinger 2002-09-27 18:33:43 UTC
This patch should fix your problems.

the valve was never handling ServletException when looking for errorpages.

see SRV.9.9.2
Comment 5 John Trollinger 2002-09-27 18:42:15 UTC
Created attachment 3271 [details]
o.a.c.v.ErrorDispatcherValve newer patch
Comment 6 John Trollinger 2002-09-27 18:44:24 UTC
The second patch conforms to the spec.. the first still did things backwords..

<quote>
The web application may have declared error pages using the exception-type
element. In this case the container matches the exception type by comparing the
exception thrown with the list of error-page definitions that use the 
exceptiontype element. A match results in the container returning the resource 
indicated in the location entry. The closest match in the class heirarchy wins.

If no error-page declaration containing an exception-type fits using the
class-heirarchy match, and the exception thrown is a ServletException or
subclass thereof, the container extracts the wrapped exception, as defined by 
the ServletException.getRootCause method. A second pass is made over the error
page declarations, again attempting the match against the error page 
declarations, but using the wrapped exception instead.
</quote>

as you can see it needs to check for the ServletException first, and if a page 
is not found for them then it needs to check the root cause..

or atleast that is how I read it..
Comment 7 John Trollinger 2002-09-27 18:47:48 UTC
Created attachment 3272 [details]
o.a.c.v.ErrorDispatcherValve even newer.. one of those days....