Return-Path: Delivered-To: apmail-cxf-users-archive@www.apache.org Received: (qmail 96160 invoked from network); 13 May 2009 14:07:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 May 2009 14:07:32 -0000 Received: (qmail 82471 invoked by uid 500); 13 May 2009 14:07:31 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 82239 invoked by uid 500); 13 May 2009 14:07:30 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 82219 invoked by uid 99); 13 May 2009 14:07:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 May 2009 14:07:27 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [192.77.186.20] (HELO mx4.progress.com) (192.77.186.20) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 May 2009 14:07:17 +0000 Received: from mx4.progress.com (127.0.0.1) by mx4.progress.com (MlfMTA v3.2r9) id h1ba1k0171sv for ; Wed, 13 May 2009 10:07:01 -0400 (envelope-from ) Received: from progress.com ([192.233.92.16]) by mx4.progress.com (SonicWALL 6.2.2.1073) with ESMTP; Wed, 13 May 2009 10:07:01 -0400 Received: from NTEXFE01.bedford.progress.com (ntexfe01 [10.128.10.24]) by progress.com (8.13.8/8.13.8) with ESMTP id n4DE6uFQ005131 for ; Wed, 13 May 2009 10:06:56 -0400 (EDT) Received: from sberyoz ([10.5.2.18]) by NTEXFE01.bedford.progress.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 13 May 2009 10:06:56 -0400 Message-ID: <010b01c9d3d4$12dcaf70$1202050a@emea.progress.com> From: "Sergey Beryozkin" To: References: <26AA63832ED7774DBFB9FFB39B337C00A0DE9F0F@nj0cech03.lnholdings.com> <26AA63832ED7774DBFB9FFB39B337C00A0DEA51F@nj0cech03.lnholdings.com> Subject: Re: JAXRS outFaultInterceptors Date: Wed, 13 May 2009 15:06:52 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 X-OriginalArrivalTime: 13 May 2009 14:06:56.0430 (UTC) FILETIME=[13221CE0:01C9D3D4] X-Mlf-Version: 6.2.2.1073 X-Mlf-UniqueId: o200905131407010314928 X-Virus-Checked: Checked by ClamAV on apache.org Hi, What exactly is not working when registering proviers programmatically ? Are exception mappers not invoked ? I've added a test which tries to follow your example pretty closely : http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBeanTest.java May be you can try to check, just for a test, a resulting ProviderFactory, same way it's done in the test I linked to ? Cheers, Sergey ----- Original Message ----- From: "Vitaly Peressada" To: Sent: Tuesday, May 12, 2009 3:33 PM Subject: RE: JAXRS outFaultInterceptors Hi, One more question on configuring ExceptionMappers programmatically. Spring configuration works as per below but following doesn't JAXRSServerFactoryBean jaxrsBean = new JAXRSServerFactoryBean(); jaxrsBean.setResourceClasses(this.getClass()); jaxrsBean.setResourceClasses(this.getClass()); jaxrsBean.setResourceProvider(this.getClass(), new SingletonResourceProvider(this)); InfraredExceptionMapper iem = new InfraredExceptionMapper(); RuntimeExceptionMapper rem = new RuntimeExceptionMapper(); List providers = new ArrayList(); providers.add(iem); providers.add(rem); jaxrsBean.setProviders(providers); this.endpointUrl = "http://" + InetAddress.getLocalHost().getCanonicalHostName() + ":" + String.valueOf(this.getListenPort()) + "/"; jaxrsBean.setAddress(this.endpointUrl); server = jaxrsBean.create(); server.start() I guess setProviders(...) registers them as entityProviders. How should I register them? Vitaly -----Original Message----- From: Sergey Beryozkin [mailto:sberyozk@progress.com] Sent: Monday, May 11, 2009 3:47 PM To: users@cxf.apache.org Subject: RE: JAXRS outFaultInterceptors 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:vperessada@liquidnet.com] Sent: 11 May 2009 19:01 To: users@cxf.apache.org Subject: RE: JAXRS outFaultInterceptors Thanks for your help, ExceptionMapper does work for me. -----Original Message----- From: Sergey Beryozkin [mailto:sberyozk@progress.com] Sent: Saturday, May 09, 2009 10:49 AM To: users@cxf.apache.org 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 & ExceptionMapper, 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:vperessada@liquidnet.com] Sent: 08 May 2009 21:50 To: users@cxf.apache.org 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:sberyozk@progress.com] Sent: Friday, May 08, 2009 4:29 PM To: users@cxf.apache.org Subject: RE: JAXRS outFaultInterceptors Hi > Try 1 > Use > Spring complained I will investigate. In meantime, you might want to implement a JAXRS ExceptionMapper 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:vperessada@liquidnet.com] Sent: 08 May 2009 21:10 To: users@cxf.apache.org 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 Spring complained Try2 Where exceptionInterceptor is public class ExceptionInterceptor extends AbstractPhaseInterceptor { 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