How to handle ClientAbortException in CXF ?

2015-12-23 Thread Sumit Arora
Hi All, I have made a web application, which uses Apache CXF on backend. In many situation - Client(user) uses the web application to fetch some data to view ( say click on button) which CXF web service provide from the backend, But Client closes the browser, however the cxf web service was

Re: How to handle ClientAbortException in CXF ?

2015-12-23 Thread Sergey Beryozkin
Hi JAXRSOutInterceptor.handleWriteException checks JAX-RS ExceptionMapper so perhaps you can intercept that Exception and return Response with the code only from this exception mapper. Another option to try is to wrap Jackson with a custom JAX-RS MessageBoryWriter and handle the write

Re: How to handle ClientAbortException in CXF ?

2015-12-23 Thread Sumit Arora
Sergey, I tried using to write Exception Mapper : 1.Here MapperException - > IOException, ClientErrorException public class GTMClientExceptionMapper implements ExceptionMapper { public Response toResponse(IOException ce) { ErrorMessage errorMessage = new

Re: How to handle ClientAbortException in CXF ?

2015-12-23 Thread Sumit Arora
It comes here on exception mapper : public class GTMClientExceptionMapper implements ExceptionMapper { public Response toResponse(IOException ce) { // ErrorMessage errorMessage = new ErrorMessage(ce.getMessage(),400,"Exmaple Message "); return null; // return

Re: How to handle ClientAbortException in CXF ?

2015-12-23 Thread Sergey Beryozkin
Well, first thing to check is whether this mapper is invoked, note it is not auto-discovered by default, unless you explicitly enable the auto-discovery, so it needs to be registered in jaxrs:providers. But even if it is invoked, the problem is you still try to return some error message - the

Re: How to handle ClientAbortException in CXF ?

2015-12-23 Thread Sumit Arora
I have tried that as well, that didn't work : @Provider public class GTMGenericExceptionMapper implements ExceptionMapper { public Response toResponse(Throwable th) { ErrorMessage errorMessage = new ErrorMessage(th.getMessage(),500,"Example Message"); return

Re: How to handle ClientAbortException in CXF ?

2015-12-23 Thread Sergey Beryozkin
Try registering ExceptionMapper and see what happens Cheers. Sergey On 23/12/15 16:03, Sumit Arora wrote: Sergey, I tried using to write Exception Mapper : 1.Here MapperException - > IOException, ClientErrorException public class GTMClientExceptionMapper implements ExceptionMapper {

Re: How to handle ClientAbortException in CXF ?

2015-12-23 Thread Sergey Beryozkin
As I have already said, return Response with the error code only. Returning null indicates to the runtime that the mapping has not been done in which case it has to rethrow the original exception. If returning a response with the code only does not help then move to the alternative 2 (write

NPE in getMessageId() while receiving soap fault response

2015-12-23 Thread Sergey Maslov
Hi! I call external service via CXF client and I want to log outgoing and incoming messages. Requests logs successfully, but I could not log response if response contains SoapFault. I get NPE instead. Could you help me to log the response? Exception and response are listed below.

RE: Dynamically set policy via message property

2015-12-23 Thread ellen
Hi Andrei, Thanks a lot for your suggestion. :) I found a good way to do that, cxf has a org.apache.cxf.ws.policy.attachment.external.ExternalAttachmentProvider, which can read external policy attachment file, like: http://www.w3.org/ns/ws-policy; xmlns:test="http://x.y.z/Assertions;>