Bug 59966 - Wrong configured error-page elements in deployment descriptor will become the fallback error-page
Summary: Wrong configured error-page elements in deployment descriptor will become the...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.5.x-trunk
Hardware: All All
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-10 15:43 UTC by saschakarcher
Modified: 2016-08-11 20:20 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description saschakarcher 2016-08-10 15:43:18 UTC
Example scenario:

web.xml contains the following block:

...
<error-page>
  <error-code>java.lang.Throwable</error-code>
  <location>/unexpected.jsp</location>
</error-page>
...

This block wrongly contains "error-type" instead of "error-code".
When this application is deployed the error-page is registered as the default error page because org.apache.tomcat.util.descriptor.web.ErrorPage#setErrorCode catches NumberFormatException and assumes errorCode 0.

Then later when a request to a servlet is made which uses the sendError (e.g. with 404) method the page "unexpected.jsp" is displayed instead of the default 404 page.

It's also related to org.apache.catalina.core.StandardHostValve#status(Request request, Response response) where it says:
...
 ErrorPage errorPage = context.findErrorPage(statusCode);
        if (errorPage == null) {
            // Look for a default error page
            errorPage = context.findErrorPage(0);
        }
...

"context.findErrorPage(0)" returns "/unexpected.jsp" although it should return null.
Comment 1 Mark Thomas 2016-08-11 20:20:08 UTC
Thanks for the report. This has been fixed in the following branches:
- 9.0.x for 9.0.0.M10 onwards
- 8.5.x for 8.5.5 onwards
- 8.0.x for 8.0.37 onwards
- 7.0.x for 7.0.71 onwards