Return-Path: Delivered-To: apmail-cxf-users-archive@www.apache.org Received: (qmail 11741 invoked from network); 21 Nov 2008 11:15:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Nov 2008 11:15:46 -0000 Received: (qmail 24794 invoked by uid 500); 21 Nov 2008 11:15:53 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 24726 invoked by uid 500); 21 Nov 2008 11:15:52 -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 24714 invoked by uid 99); 21 Nov 2008 11:15:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Nov 2008 03:15:52 -0800 X-ASF-Spam-Status: No, hits=3.7 required=10.0 tests=FAKE_REPLY_C,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [192.77.186.17] (HELO mx3.progress.com) (192.77.186.17) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Nov 2008 11:14:28 +0000 Received: from mx3.progress.com (127.0.0.1) by mx3.progress.com (MlfMTA v3.2r9) id h4qc5a0171sn for ; Fri, 21 Nov 2008 06:15:13 -0500 (envelope-from ) Received: from progress.com ([192.233.92.16]) by mx3.progress.com (SonicWALL 6.2.2.1073) with ESMTP; Fri, 21 Nov 2008 06:15:13 -0500 Received: from NTEXFE01.bedford.progress.com (ntexfe01 [10.128.10.24]) by progress.com (8.13.8/8.13.8) with ESMTP id mALBFD5o027298 for ; Fri, 21 Nov 2008 06:15:13 -0500 (EST) Received: from sberyoz ([10.5.2.224]) by NTEXFE01.bedford.progress.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 21 Nov 2008 06:15:12 -0500 Message-ID: <00fb01c94bca$72c35250$e002050a@emea.progress.com> From: "Sergey Beryozkin" To: "Sergey Beryozkin" , Subject: Re: JAX-RS in an OSGI bundle Date: Fri, 21 Nov 2008 11:15:22 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response 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: 21 Nov 2008 11:15:12.0509 (UTC) FILETIME=[6C0DCAD0:01C94BCA] X-Mlf-Version: 6.2.2.1073 X-Mlf-UniqueId: o200811211115130201596 X-Virus-Checked: Checked by ClamAV on apache.org I was so excited that I pressed Send too early :-). So here it goes again Another hurdle which might be lurking around, after you get past this one, is the whole FactoryFinder thing. ServiceMix4 does some cool things in this regard, specifically Guillaume added an Osgi locator bundle plus OSGI-fied versions of jaxws-api,stax-api etc. Osgi locator bundle will scan preexisting and newly installed bundles for their META-INF/services data, if any and record them, while OSGI-fied api bundles will also rely on Osgi locator to help them to find the factory implemenetation. We'll need to submit an osgified jaxrs api bundle to the SMX4 spec project. Cheers, Sergey ----- Original Message ----- From: "Sergey Beryozkin" To: Sent: Friday, November 21, 2008 11:09 AM Subject: Re: JAX-RS in an OSGI bundle > Hi, > > Another hurdle which might be lurking around, after you get past this one, is the whole FactoryFinder thing. > ServiceMix4 does some cool things in thi sregard, specifically Gui > ----- Original Message ----- > From: "Sergey Beryozkin" > To: > Sent: Friday, November 21, 2008 10:09 AM > Subject: Re: JAX-RS in an OSGI bundle > > >> Hi Josh >> >> >>> I'm trying to publish a rest-style web service from an OSGI bundle. >> >> You're ahead of us in trying to do it :-). >> I've not had time at all to look into publishing JAXRS endpoint into OSGI containers but I will. >> I'll definitely look into making sure CXF JAXRS-based endpoints play nice in the OSGI environment too. In fact I'd expect them to >> work and eventually be accessible in the Distributed OSGI environment too. >> >>> I've installed the cxf-bundle-2.2-SNAPSHOT.jar bundle (built from the trunk today) into apache felix. Here's the code, copied >>> directly from the cxf documentation. >>> >>> JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); >>> sf.setResourceClasses(SampleRestServiceImpl.class); >>> sf.setAddress("http://localhost:8000/"); >>> sf.create(); >>> >> >> I'll need to have a look and see what is that JAXRSServerFactoryBean is missing, as compared to Endpoint.publish. It's either >> setting the default bus or context loader is wrong. >> >> One hack I used to rely upon is to setting a thread context loader to the one which loaded say JAXRSServerFactoryBean.class just >> before the code you do above, this will be an OSGI container class loader and often it helped. >> >> Another thing to try is Spring OSGI. It works in most cases really. In this case you'd need to use jaxrs:server configuration and >> put it into META-INF/spring in your bundle. >> For ex, if you look at [1], you can see all the spring bundles which need to be installed (I think you can fine spring bundles >> which encompass all of them so you'd need to install up to 2-3 bundles max) : >> >> // the first 5 bundles are Spring bundles, we used a single Spring bundle (spring.jar or spring-all.jar ?) available from Spring >> repo earlier : >> start file:${maven.repo.local}/org/springframework/spring-core/${spring.version}/spring-core-${spring.version}.jar >> start file:${maven.repo.local}/org/springframework/spring-beans/${spring.version}/spring-beans-${spring.version}.jar >> start file:${maven.repo.local}/org/springframework/spring-context/${spring.version}/spring-context-${spring.version}.jar >> start file:${maven.repo.local}/org/aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-1.0.0.jar >> start file:${maven.repo.local}/org/springframework/spring-aop/${spring.version}/spring-aop-${spring.version}.jar >> >> // Spring OSGI bundles >> >> start >> file:${maven.repo.local}/org/springframework/osgi/spring-osgi-io/${spring.osgi.version}/spring-osgi-io-${spring.osgi.version}.jar >> >> start >> file:${maven.repo.local}/org/springframework/osgi/spring-osgi-core/${spring.osgi.version}/spring-osgi-core-${spring.osgi.version}.jar >> >> start >> file:${maven.repo.local}/org/springframework/osgi/spring-osgi-extender/${spring.osgi.version}/spring-osgi-extender-${spring.osgi.version}.jar >> >> >> So if you drop those ones into Felix and then deploy a JAXRS bundle with the Spring config involved then it might work just fine. >> You might want tosave yourself some time and quickly try a ServiceMix4 distribution which uses Felix and has all the Spring and >> Soring OSGI bundles preinstalled >> >> Let me know how it all goes please and in meantime I'll try to fix the direct endpoint publication >> >> Cheers, Sergey >> >>> The stack trace I'm getting is this: >>> >>> Nov 20, 2008 12:57:31 PM org.apache.cxf.BusFactory newInstance >>> SEVERE: Failed to instantiate bus factory. >>> java.lang.ClassCastException: class org.apache.cxf.bus.spring.SpringBusFactory >>> at java.lang.Class.asSubclass(Class.java:2979) >>> at org.apache.cxf.BusFactory.newInstance(BusFactory.java:164) >>> at org.apache.cxf.BusFactory.newInstance(BusFactory.java:140) >>> at org.apache.cxf.BusFactory.getDefaultBus(BusFactory.java:69) >>> at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:106) >>> at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:97) >>> at org.apache.cxf.endpoint.AbstractEndpointFactory.getBus(AbstractEndpointFactory.java:73) >>> at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.createEndpointInfo(JAXRSServerFactoryBean.java:180) >>> at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.createEndpoint(JAXRSServerFactoryBean.java:146) >>> at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:88) >>> >>> Publishing wsdl-based web services using Endpoint.publish(address, webService) works just fine. >>> >>> Any ideas what's up with my JAX-RS code / configuration? >>> >>> Thanks, >>> Josh >>> >>> >> >> >> >