users@jersey.java.net

Error message with ExceptionMapper not visible (Tomcat)

From: Casper Bang <casper.bang_at_gmail.com>
Date: Mon, 14 Dec 2009 19:33:30 +0100

I implemented a 400 ExceptionMapper in order to adhere to REST
best-practices, upon receiving a semantically incorrect request:

@Provider
public class SemanticExceptionMapper implements
ExceptionMapper<SemanticException> {
    @Override
    public Response toResponse(SemanticException ex) {
        return Response.status(400)
                .entity(ex.getMessage())
                .type("text/plain")
                .build();
    }
}

It works fine except very little (well nothing) of the error message is
revealed to the user. This could be container specific I suppose (I'm
using Tomcat 6.x) or a visibility/security issue. Would anyone know
about this? The specs says "...may contain a document describing why the
server thinks there's a client-side error".

Thanks in advance,
Casper