cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <sergey.beryoz...@progress.com>
Subject Re: JAX-RS in an OSGI bundle
Date Fri, 21 Nov 2008 11:15:22 GMT
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" <sergey.beryozkin@progress.com>
To: <users@cxf.apache.org>
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" <sergey.beryozkin@progress.com>
> To: <users@cxf.apache.org>
> 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
>>>
>>>
>>
>>
>>
> 



Mime
View raw message