I have an EE6 JAX-RS application that runs on Jboss 7 (EAP 6.4) and handles most of its exceptions and errors internally through an implementation of ExceptionMapper
.
There are circumstances, though, (most notably when HTTP Basic Auth fails) when this is not invoked because the error occurs before the application is invoked, and thus the client gets the server's default error page (JBWEB bla bla, HTML with ugly purple colors).
Now in order to catch these "outer" errors I added <error-page>
definitions to web.xml
like so:
<error-page>
<location>/error.json</location>
</error-page>
<error-page>
<error-code>401</error-code>
<location>/error401.json</location>
</error-page>
The location works fine and I almost get the response I want but the HTTP status code is always 200.
That is annoying, to say the least. How do I get the error page to return its proper error code?