My understanding is that the exception mapper is responsible to decide what content type it produces. The exception mapper doesn't even know the resource method where the exception is thrown unless the exception itself carries the desired media type.
Sent from my iPad On Mar 8, 2012, at 6:57 PM, Cameron Dalton <[email protected]> wrote: > Hello, > > After an ExceptionMapper runs, the MediaType seems to incorrectly be > considered “text/html” instead of the “application/json” declared in the > resource method’s @Produces annotation. > > The resource method has @Produces(MediaType.APPLICATION_JSON), and the client > is successfully getting a JSON response after the “happy path”. > > However, when the resource method throws an Exception and the ExceptionMapper > runs, the subsequent RequestHandler chain sees the MediaType as “text/html” > instead of “application/json”. This would be annoying in and of itself since > the client would get an unexpected content type, however this is actually > causing an IOException because Wink delegates the “text/html” responses to > the class com.sun.mail.handlers.text_plain (???) which blows up with any > entity type other than String. > > Why is this MediaType coming back as “text/html” after an ExceptionMapper > runs, when both the client and the resource have agreed on > “application/json”? What can I do to correct or alter this behavior? > > Thanks for any insight you can provide! > > Cameron >
