Description of problem: A custom error page is configured in web.xml for each HTTP error status but the behaviour is inconsistent. For example, the page is returned for "404 File Not Found" and "415 Unsupported Media Type", but not for "405 Method Not Allowed". It seems the response has been already committed in the 405 case. Version-Release number of selected component (if applicable): EAP 6.3.0 (resteasy-jaxrs-2.3.8.Final-redhat-3.jar) EAP 6.4.6 (resteasy-jaxrs-2.3.12.Final-redhat-1.jar) EAP 7.0.b (resteasy-jaxrs-3.0.13.Final-redhat-1.jar) * EAP 7 behaves in more different way. How reproducible: Always. Steps to Reproduce: 1. Deploy attached xxx.yyy.zzz.war. 2. Try the following URLs. curl -i http://localhost:8080/test/xyz/foo -X POST -H 'Content-Type:application/json' => 200 OK request curl -i http://localhost:8080/test/xyz/foo -X POST => 415 Unsupported Media Type with the custom error page curl -i http://localhost:8080/test/xyz/foo1 -X POST -H 'Content-Type:application/json' => 404 File Not Found with the custom error page curl -i http://localhost:8080/test/xyz/foo -X GET => 405 Method Not Allowed with the default error page Expected results: The custom error page should be returned for 405 too. Additional info: If you use ExceptionMapper like this, the returned contents can be customized. ~~~ package xyz; import org.jboss.resteasy.spi.MethodNotAllowedException; import javax.ws.rs.core.Response; import javax.ws.rs.ext.Provider; import javax.ws.rs.ext.ExceptionMapper; @Provider public class CustomErrorPage implements ExceptionMapper<MethodNotAllowedException> { public Response toResponse(MethodNotAllowedException exception) { System.out.println("Custom Exception " + exception.getMessage()); return Response.status(405).entity("test").build(); } } ~~~
Created attachment 1134399 [details] xxx.yyy.zzz.war Hi, I'm very sorry that I forgot to attach the war file, xxx.yyy.zzz.war.
In JBossWeb, https://source.jboss.org/browse/JBossWeb/branches/7.5.x/src/main/java/org/apache/catalina/core/StandardHostValve.java?hb=true#to424 When http status code is 405, it will return immediately without finding any customer error page at line: /* Only look for error pages when isError() is set. * isError() is set when response.sendError() is invoked. This * allows custom error pages without relying on default from * web.xml. */ if (!response.isError()) return; I can see the custom error page for status code 405 once I comment out the "return;" $ curl -i http://localhost:8080/test/xyz/foo -X GET HTTP/1.1 405 Method Not Allowed Server: Apache-Coyote/1.1 Allow: POST, OPTIONS Accept-Ranges: bytes ETag: W/"117-1455094050000" Last-Modified: Wed, 10 Feb 2016 08:47:30 GMT Content-Type: text/html Content-Length: 117 Date: Thu, 10 Mar 2016 09:44:43 GMT <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>.</title> </head> <body>.<!-- J --></body> But, it seems this is an expected action when response.isError() value is false as comments above the codes. More investigation is needed here, and I add web as second component for this bugzilla.
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions
Verified with EAP 6.4.10.CP.CR2
Retroactively bulk-closing issues from released EAP 6.4 cummulative patches.