I have a jaxrs endpoint service, in my own ResourceConfig
I register an ExceptionMapper
, so when somewhere wrong happened, it will return a JSON
The Jackson provider already has ExceptionMapper
s1 that will just return the exception message when an exception is caught. If you want, you can just create your own ExceptionMapper
for these exceptions, i.e. JsonParseException
and JsonMappingException
, and just return the message you want. Then just register those mappers with the Jersey application. This should override the ones registered by Jackson.
The reason your exception mapper doesn't work is because the ones from Jackson are more specific. The more specific one always gets invoked.
1 - namely JsonParseExceptionMapper and JsonMappingExceptionMapper