I've fought this all morning and I'm stumped, my ExceptionMapper is not
being invoked and it sure seems like it should be.
Here's the startup log showing the Mapper:
INFO: Provider classes found:
class adapter.exceptions.ExceptionMapper
class adapter.exceptions.WebApplicationExceptionMapper
This is the WebApplicationExceptionMapper... pretty basic:
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import org.apache.log4j.Logger;
@Provider
public class WebApplicationExceptionMapper implements
ExceptionMapper<javax.ws.rs.WebApplicationException> {
private static final Logger logger =
Logger.getLogger(WebApplicationExceptionMapper.class);
@Override
public Response toResponse(javax.ws.rs.WebApplicationException e) {
logger.debug("Mapping");
e.printStackTrace();
return e.getResponse();
}
}
Throw the WebApplicationException:
throw new
WebApplicationException(Response.status(response.getStatus()).entity(new
ErrorResponse(response)).type(MediaType.APPLICATION_XML).build());
See it come back:
May 24, 2012 12:41:06 PM
com.sun.jersey.api.container.filter.LoggingFilter$Adapter finish
INFO: 1 * Server out-bound response
1 < 400
1 < Content-Type: application/xml
1 <
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?><error><error_code>CO:400</error_code><error_detail>{error:invalid_grant}</error_detail><error_message>Bad
Request</error_message></error>
The return is exactly as it should be, but no log4j message or stack trace
in the server's log. Suggestions?
Thanks-- Mike