My suspicion is that it is due to JAXRSOutInterceptor being in the MARSHAL phase at which point it may be too late to change the response-code. But I don't know the interceptor chain well enough to be sure of that.
Benji -----Original Message----- From: Benji Shults [mailto:[email protected]] Sent: Monday, February 27, 2012 1:47 PM To: [email protected] Subject: RE: response_code 500 ignored when set in JAXRSOutInterceptor.handleWriteException Glen, I'm using CXF 2.5.2. I haven't made any changes to JAXRSOutInterceptor. The only interceptors I've added are the built-in LoggingIn/OutInterceptors. When JAXRSOutInterceptor calls writer.writeTo, that writer writes to the message's outputStream then throws an exception. Looking at the code in JAXRSOutInterceptor, I see that it does this: message.put(Message.RESPONSE_CODE, 500) // line 362 However, my HTTP client sees a response code of 200. The writer I wrote myself and introduced it using the following: <jaxrs:providers> <bean class="com.ecologic.sdc.webservice.JsonUsageResponseValidatingProvider" /> </jaxrs:providers> Benji -----Original Message----- From: Glen Mazza [mailto:[email protected]] Sent: Monday, February 27, 2012 1:39 PM To: [email protected] Subject: Re: response_code 500 ignored when set in JAXRSOutInterceptor.handleWriteException Can you give a very generic version of that interceptor that would duplicate/demonstrate the problem? Glen On 02/27/2012 02:36 PM, Benji Shults wrote: > I have a scenario where the call to writer.writeTo in > JAXRSOutInterceptor.serializeMessage throws an exception. > > Before throwing the exception, the writer writes to the message's > outputStream. > > When write.writeTo throws the exception, handleWriteException calls > message.put(Message.RESPONSE_CODE, 500). > > However, my HTTP client is seeing the response come back with HTTP > response code 200. > > The following is appended to the response that the writer put into the > message's outputStream: > > Error serializing the response, please check the server logs, response > class : UsageResponse. > > Benji > -- Glen Mazza Talend Community Coders - coders.talend.com blog: www.jroller.com/gmazza
