I am using the RESTEasy Spring MVC integration (springmvc-resteasy using RestEasy 2.0, Spring 3.0) I would like to map my application exceptions to HTTP responses by declaring the RESTEasy exception mapping providers. Currently my application does not explicitly extend javax.ws.rs.core.Application and ideally I would like to rely on the framework's automatic scanning of exception mapping providers.
Here is what one of my exception mappers looks like.
@Provider public class MyAppExceptionMapper implements ExceptionMapper<MyAppException> {
public Response toResponse(MyAppException exception) {
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
And my exception class looks like this
public class MyAppException extends RuntimeException {
public MyAppException(String s, Throwable t) {
super(s,t);
}
}
When my application throws a MyAppException, it does not get mapped to a HTTP-400 response (I get the usual HTTP-500 from the framework)
Is there something I am missing? If this is a problem with not "registering" the provider with the framework, how do I register my exception mappers when I am using springmvc-resteasy?
Thanks.