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.
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.
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.
Created attachment 3270 [details] o.a.c.v.ErrorDispatcherValve patch
This patch should fix your problems. the valve was never handling ServletException when looking for errorpages. see SRV.9.9.2
Created attachment 3271 [details] o.a.c.v.ErrorDispatcherValve newer patch
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..
Created attachment 3272 [details] o.a.c.v.ErrorDispatcherValve even newer.. one of those days....