I'm not sure with 2.2.11. With 2.3.2 you can definitely stick an interceptor
early in the "in" chain and in the handleFault method, you can grab the
exception and change it to a different exception:
Exception ex = msg.getContent(Exception.class);
if (ex is Read timed out) {
msg.setContent(Exception.class, new ThisIsMyException());
}
or similar. It would then output that exception usiing the normal fault
chain.
Obviously, youcan stick an interceptor out early in the FaultOut and
accomplish that as well.
Dan
On Friday 04 February 2011 4:53:09 pm Andrew wrote:
> Hi,
>
> I'm doing some basic stress testing of my JAX-RS service and getting back
> some 500 responses, with body:
>
> JAXBException occurred : Read timed out. Read timed out.
>
> and
>
> <ns1:XMLFault
> xmlns:ns1="http://cxf.apache.org/bindings/xformat"><ns1:faultstring
> xmlns:ns1="http://cxf.apache.org/bindings/xformat">java.net.SocketTimeoutE
> xception: Read timed out</ns1:faultstring></ns1:XMLFault>
>
> On the service side I see the exceptions logged at WARN:
>
> 2011-02-04 14:19:57,621 [http-8080-5] WARN
> org.apache.cxf.phase.PhaseInterceptorChain[369] - Interceptor for {
> http://foo.com/}CommandResourceImpl has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Read timed out
> at
> org.apache.cxf.interceptor.LoggingInInterceptor.logging(LoggingInIntercepto
> r.java:201)
>
> 2011-02-04 14:19:57,928 [http-8080-38] WARN
> org.apache.cxf.jaxrs.provider.AbstractJAXBProvider[508] -
> javax.xml.bind.UnmarshalException
> - with linked exception:
> [org.xml.sax.SAXParseException: Premature end of file.]
>
> but I'd like to handle these exceptions myself. Is there a way to capture
> these exceptions on the service side? I'm using CXF 2.2.11 Thanks,
>
> Andrew
--
Daniel Kulp
[email protected]
http://dankulp.com/blog