Hi

There is a default WebApplicationExceptionMapper out there which maps an 
exception into the Response. The empty body in this specific case is actually 
mandated by the JAX-RS spec. You can register your own custom 
WebApplicationExceptionMapper or you can register a custom ResponseHandler 
filter and override a Response returned by the default mapper

Sergey

-----Original Message-----
From: Mike O'Neil [mailto:[email protected]] 
Sent: 17 December 2009 21:12
To: [email protected]
Subject: Re: Fault thrown in Rest In-Interceptor not handled by ExceptionMapper

Thanks for your response. I gave this a shot and it seems to work
pretty well, though is a lot more cumbersome, seeing as how we need to
handle the marshalling directly. Unfortunately this also introduces a
different place where an exception is not properly handled: when
trying to find the target method in JAXRSUtils, if not found, a
WebApplicationException is thrown but the custom fault out interceptor
is not invoked. This results in an empty body in the HTTP response.
Have you run into that?

Thanks for your help,
Mike

On Thu, Dec 17, 2009 at 3:25 PM, vickatvuuch <[email protected]> wrote:
>
> I have had a similar problem and worked it around by building a
> CustomFaultOutInterceptor,
> which handles everything that gets thrown for both REST and SOAP. Once you
> have a single place to do it
> you can translate Exception into HTTP response codes as well as you can
> enchance
> the default Soap fault as appropriate.
>
>
> Mike O'Neil-2 wrote:
>>
>> I have an ExceptionMapper which handles exceptions from my Rest
>> service just fine. However when my "In" Interceptor throws a Fault,
>> the ExceptionMapper does not handle it. Instead I get the standard
>> (ugly) XML, e.g.:
>>
>>     <ns1:XMLFault><ns1:faultstring>error
>> message</ns1:faultstring></ns1:XMLFault>
>>
>> Is that the expected behavior? My server is set up like:
>>
>> <jaxrs:server id="service" address="/rest">
>>         <jaxrs:serviceBeans>
>>             <bean parent="myService" />
>>         </jaxrs:serviceBeans>
>>         <jaxrs:inInterceptors>
>>             <ref bean="myInterceptor"/>
>>         </jaxrs:inInterceptors>
>>         <jaxrs:providers>
>>             <ref bean="restExceptionMapper"/>
>>         </jaxrs:providers>
>> </jaxrs:server>
>>
>>
>> And my interceptor looks like:
>>
>> public class MyInterceptor extends AbstractPhaseInterceptor<Message> {
>>     public FormatSettingInterceptor() {
>>         super(Phase.PRE_STREAM);
>>     }
>>
>>     @Override
>>     public void handleMessage(Message message) throws Fault {
>>             throw new Fault("Not handled by ExceptionMapper!");
>>     }
>> }
>>
>> Any insight or help would be appreciated.
>>
>> Much thanks,
>> Mike
>>
>>
>
> --
> View this message in context: 
> http://old.nabble.com/Fault-thrown-in-Rest-In-Interceptor-not-handled-by-ExceptionMapper-tp26833555p26834406.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>

Reply via email to