[undertow-dev] Undertow not handling servlet exceptions properly

Dragan Jotanovic draganj at gmail.com
Tue May 20 08:45:20 EDT 2014


Hi,

I'm using embedded undertow with jastow for serving jsp pages.
I registered custom error page for handling all 500 errors, but exception
is not propagated to my custom 500.jsp page (javax.servlet.error.exception
request attribute is never set).
I debugged through undertow code and found that the problem is in
"ServletInitialHandler",  "handleFirstRequest" method. When a servlet
throws exception, error page location is looked for only by exception type
and not by exception code as well, so the exception is never propagated to
my custom error page.
Is this a bug or a feature? The only workaround I have found is to register
my custom error page against JasperException.class, but I wouldn't want to
do this for all the possible exceptions my application could throw.

If it's a bug, than simple fix would be to look for error page by 500 error
code as well, like so:

String location =
servletContext.getDeployment().getErrorPages().getErrorLocation(t);
if (location == null) {
    location =
servletContext.getDeployment().getErrorPages().getErrorLocation(500);
}

Regards,
Dragan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20140520/86166fbb/attachment.html 


More information about the undertow-dev mailing list