Bug 59966

Summary: Wrong configured error-page elements in deployment descriptor will become the fallback error-page
Product: Tomcat 8 Reporter: saschakarcher
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 8.5.x-trunk   
Target Milestone: ----   
Hardware: All   
OS: All   

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