Hi It's great. By the way, I think the reason you don't see custom invokers working is that that enhancement is currently only available in snapshots, so sorry for the confusion, I'll update the docs
Cheers, Sergey -----Original Message----- From: Vitaly Peressada [mailto:[email protected]] Sent: 11 May 2009 19:01 To: [email protected] Subject: RE: JAXRS outFaultInterceptors Thanks for your help, ExceptionMapper does work for me. -----Original Message----- From: Sergey Beryozkin [mailto:[email protected]] Sent: Saturday, May 09, 2009 10:49 AM To: [email protected] Subject: RE: JAXRS outFaultInterceptors So why can't you use ExceptionMappers for this purpose ? You can register as many mappers as you like. You might want to register single RuntimeException mapper which will catch everything or you can do ExceptionMapper<RuntimeException> & ExceptionMapper<MyAppException>, etc... But I will also have a look at why fault interceptors are not invoked... > http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-Custominvokers This has to work, I was able to hit a breakpoint in my system test... Please try http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apa che/cxf/systest/jaxrs/security/JAXRSSpringSecurityInterfaceTest.java#tes tGetBookUser, specifically see getBook(endpointAddress, "baddy", "baddyspassword", 403); This one works only due to http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apa che/cxf/systest/jaxrs/CustomJAXRSInvoker.java as otherwise "baddy" would've got 200 response. You might want to try to quickly build 'mvn install -Pfastinstall' the source, change launchServer(BookServerSecuritySpringInterface.class)); to launchServer(BookServerSecuritySpringInterface.class, true)); and try to hit a breakpoint... cheers, Sergey -----Original Message----- From: Vitaly Peressada [mailto:[email protected]] Sent: 08 May 2009 21:50 To: [email protected] Subject: RE: JAXRS outFaultInterceptors I did see ExceptionMapper but even after implementing it I would not solve my design problem. I want to find a single central place in CXF JAXRS stack where I can: try { // invoke service } catch (MyAppException me) { ServerError se = new ServerError(); se.setErrorCode(me.getError().ordinal()); se.setErrorMessage(me.getError().name()); return Response.error().entity(se).build(); } catch (RuntimeException re) { ServerError se = new ServerError(); se.setErrorCode(StatusCode.INTERNAL_SERVER_ERROR); se.setErrorMessage(StatusCode.INTERNAL_SERVER_ERROR.name()); return Response.error().entity(se).build(); } By the way, I also tried http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-Custominvokers but was not able to hit breakpoint on exception. Any other ideas? If not, I guess I had to resort to Spring AOP method interceptors... -----Original Message----- From: Sergey Beryozkin [mailto:[email protected]] Sent: Friday, May 08, 2009 4:29 PM To: [email protected] Subject: RE: JAXRS outFaultInterceptors Hi > Try 1 > Use <jaxrs: outFaultInterceptors> > Spring complained I will investigate. In meantime, you might want to implement a JAXRS ExceptionMapper<YourException> instead and register it as a provider. At the moment one can't register CXF interceptors as JAXRS providers, one needs to use inInterceptors/outInterceptors instead. Thanks, Sergey -----Original Message----- From: Vitaly Peressada [mailto:[email protected]] Sent: 08 May 2009 21:10 To: [email protected] Subject: JAXRS outFaultInterceptors I am trying to setup a custom exception handler which would catch exception from service methods and translate them in Response.error and custom xml. Try 1 Use <jaxrs: outFaultInterceptors> Spring complained Try2 <jaxrs:server id="infraRedAuthenticationServiceJaxrs" address="/user"> <jaxrs:providers> <ref bean="authInterceptor"/> <ref bean="exceptionInterceptor"/> </jaxrs:providers> <jaxrs:serviceBeans> <ref bean="userService"/> </jaxrs:serviceBeans> </jaxrs:server> Where exceptionInterceptor is public class ExceptionInterceptor extends AbstractPhaseInterceptor<Message> { public ExceptionInterceptor() { this(Phase.MARSHAL); } public ExceptionInterceptor(String phase) { super(phase); } @Override public void handleMessage(Message message) throws Fault { message.toString(); } @Override public void handleFault(Message message) { super.handleFault(message); } } but my break points are not hit when throwing exception from service method @GET @Path("/generalexception") public Response throwUserException() throws Exception { throw new Exception("Foo"); } Vitaly
