users@glassfish.java.net

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

From: <glassfish_at_javadesktop.org>
Date: Mon, 11 Jan 2010 10:15:21 PST

GlassFish (or the built-in Tomcat servlet container) seems to display an HTML error page only when I don't provide an entity (body) in the JAX-RS response when sending a status code >= 400.

In my resource methods (@GET, @POST, etc) I throw exceptions that extend WebApplicationException from JAX-RS. If I make my custom exception class look like this, then GlassFish doesn't muck with my response:

public class InvalidRequestException extends WebApplicationException {
    public InvalidRequestException(String technicalDetail, String userMessage) {
        super(Response.status(Status.BAD_REQUEST).header("Reason-Phrase",
                userMessage).entity(technicalDetail).build());
    }
}


Ryan
[Message sent by forum member 'rdelaplante' (ryan_at_ijws.com)]

http://forums.java.net/jive/thread.jspa?messageID=380126