Using CXF 2.7. Created REST service that can handle xml and json. The service is working correctly, that is depending on accept and content-type headers, the service read/write xml or json.
I want to create a custom error message. I registered custom ExceptionMapper class in the <jaxrs:provider>. This class extends ExceptionMapper<WebApplicationException>. When I submit a request with a bad message, my custom exception mapper kicks in and I receive the custom error message in either xml or json, depending on the accept header. However, if I send a request to a non-existing service, or submit a POST to a service that only handle GET, my custom exception mapper still kicks in but I receive the 'No message body writer has been found for response class MyError' error message. I did a bit of tracing. In JAXRSOutInterceptor, method serializeMessage, the call to computeAvailableContentTypes returns an empty array in the case I get the error. Since the array is empty, it skip the loop where it is supposed to set the writers object. I can hard code a media type to the response object in my custom exception mapper to either application/xml or application/json and it work. But that is defeating the purpose of accept header where it should create the message in the requested format. How do I get my custom error message to be marshalled in the requested format for all WebApplicationException? Thanks Francois -- View this message in context: http://cxf.547215.n5.nabble.com/Custom-ExceptionMapper-No-message-body-writer-has-been-found-for-response-class-MyError-tp5720034.html Sent from the cxf-user mailing list archive at Nabble.com.
