users@glassfish.java.net

Re: JAX-RS error code 500 = GlassFish HTML error page

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 12 Jan 2010 15:54:33 +0100

On Jan 12, 2010, at 3:25 PM, glassfish_at_javadesktop.org wrote:

>> Check out the javax.ws.rs.ext.ExceptionMapper
>> interface.
>
> Thank you. I spent some time looking at this interface and don't
> think it will change anything for me. It looks like I would create
> an exception mapper if I wanted JAX-RS to know about an existing
> exception in my application. I am throwing an exception that
> extends WebApplicationException, and the constructor does the same
> thing as the example code in the Jersey documentation.
>

I think an ExceptionMapper might be an acceptable workaround. It is
possible to support an ExceptionMapper for WebApplication and in that
mapper you could add an entity, if one is not present, e.g. a String
with one space character.


> I don't think the problem is Jersey or JAX-RS. I think when
> GlassFish sees an application returning an HTTP error code, it first
> looks to see if the application has defined error pages to display.
> If not, then it displays its own error pages. This is undesirable
> for REST APIs since it totally rewrites the headers and body. The
> only way I could find to get around it is to make sure I output an
> entity body when returning an error. Then GlassFish seems to let it
> through.
>

Another solution is to add error pages to the web.xml:

   http://java.sun.com/developer/EJTechTips/2003/tt0114.html

But ideally an option to switch off such default page support would be
most useful.

Paul.