I am implementing a basic client server architecture using REST services for the first time. This time I making it more complicated with including some more classes and serv
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.
Add this line of code before class HPCResponse
:
@XmlAccessorType(XmlAccessType.FIELD)