HTTP 500 Internal Server Error in simple REST based program. Confused in GET and POST while receiving/sending response from server

One way to debug things like this is to create a simple ExceptionMapper to catch exceptions that are not mapped. When there is no mapper, often the exception will bubble up to the container level, which just gives us generic 500 server error (which most of the time is of little help).

@Provider
public class DebugExceptionMapper implements ExceptionMapper<Exception> {

    @Override
    public Response toResponse(Exception exception) {
        exception.printStackTrace();
        return Response.serverError().entity(exception.getMessage()).build();
    } 
}

Then just register the mapper. When running a simple test with your ImageProgress class, when the exception is thrown, the stacktrace gets printed, and you can see the exception message

…ImageProgress does not have a no-arg default constructor

So just add a default (no-arg constructor) to the ImageProgress class. This is a requirement with JAXB models.

Leave a Comment