cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roll, Kevin" <Kevin-R...@idexx.com>
Subject RE: CXF in OSGi
Date Thu, 21 May 2015 14:29:42 GMT
I was able to get it working by following option 2 - I rewrote the initialization code to use
the CXF classes directly. Thanks for the advice!


-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org] 
Sent: Tuesday, May 19, 2015 4:15 PM
To: users@cxf.apache.org; Roll, Kevin
Subject: Re: CXF in OSGi


If using the pure “JAX-WS” api’s, it’s a bit tricky as the factory finder things in
the standard J2EE way of doing things requires the ContextClassLoader to be setup in a way
that the appropriate META-INF/services/* files can be found.   In OSGi, that’s pretty much
never going to be the case.   You need to use OSGi aware versions of the various api jars.
  

There are two options:

1) Update the felix config to NOT export the javax.xml.ws stuff from the System level and
then add the servicemix jaxws-api bundle into you app.  That should provide a version of the
API bundle that can find the appropriate JAX-WS implementation within OSGi.

2) Don’t use the “pure” jaxws API’s.    If you use the CXF JaxWsProxyFactoryBean to
create the clients, that forces the use of CXF as it bypasses the JAX-WS factory finder things.


The other option is to use Karaf.  Karaf handles it a bit differently.   It endorses the servicemix
jax-ws api jar (and a few other j2ee inspired api jars) so it can continue to export them
from the system, but the way Karaf endorses them also allows them to know a bit about the
OSGi runtime and class loaders which allows them to find the right implementations. 

Dan




> On May 19, 2015, at 3:57 PM, Roll, Kevin <Kevin-Roll@idexx.com> wrote:
> 
> NOTE: I'm trying to summarize a lot of info into a short post. Please read all of the
details as this is not the quick answer you might think it is.
> 
> Part of our project runs inside an OSGi container - Apache Felix, which is part of the
Apache Sling framework. We have been given a library from another team which uses CXF to access
a web service. The other team is very busy so the chances of getting support from them are
nil - we have to use whatever they gave us.
> 
> I created a module in our project to wrap the other team's jar as an OSGi bundle. The
first problem I ran into is that I encountered unresolved dependencies at runtime. I had to
manually exclude dozens of packages to get the container to start up. I'm not sure why this
is.
> 
> When I attempt to initialize this library, I get the familiar
> 
> Caused by: java.lang.ClassCastException: com.sun.xml.internal.ws.client.sei.SEIStub cannot
be cast to org.apache.cxf.frontend.ClientProxy
>   at org.apache.cxf.frontend.ClientProxy.getClient(ClientProxy.java:128)
> 
> The usual answer seems to be "make sure CXF is in your classpath". My confusion is that
I am building my own bundle and as far as I can tell it certainly is. I've gone to extra lengths
to make sure the CXF jars are in the bundle and up at the front of the classpath. This is
my bundle configuration:
> 
> 
> <plugin>
>    <groupId>org.apache.felix</groupId>
>    <artifactId>maven-bundle-plugin</artifactId>
>    <version>2.5.4</version>
>    <extensions>true</extensions>
>    <configuration>
>        <obrRepository>NONE</obrRepository>
>        <manifestLocation>META-INF</manifestLocation>
>        <instructions>
>            <Export-Package>com.idexx.imaging*</Export-Package>
>            <Import-Package>
>                !com.sun*;!junit*;!jgoodies*;!net.sf*;!org.apache.aries*;!org.apache.avalon*;
>                !org.apache.axiom*;!org.apache.cxf.tools.common*;!org.apache.cxf.tools.validator*;
>                !org.apache.geronimo*;!org.apache.log*;!org.apache.mina*;!org.junit*;!org.jvnet*;
>                !org.osgi.service*;!org.relaxng*;!org.springframework*;
>                *
>            </Import-Package>
>            <Embed-Dependency>
>                !org.apache.felix*;*;scope=compile|runtime
>            </Embed-Dependency>
>            <Embed-Transitive>true</Embed-Transitive>
>            <Bundle-ClassPath>{maven-dependencies},.</Bundle-ClassPath>
>        </instructions>
>    </configuration>
>    <executions>
>        <execution>
>            <id>bundle-manifest</id>
>            <phase>package</phase>
>            <goals>
>                <goal>bundle</goal>
>            </goals>
>        </execution>
>    </executions>
> </plugin>
> 
> The classpath in my bundle, as seen in the container, seems reasonable...
> 
> Bundle Classpath
> 
> cxf-rt-frontend-jaxws-2.7.2.jar,xml-resolver-1.2.jar,asm-3.3.1.jar,cxf-rt-core-2.7.2.jar,jaxb-impl-2.2.6.jar,cxf-rt-bindings-xml-2.7.2.jar,cxf-rt-frontend-simple-2.7.2.jar,cxf-rt-ws-addr-2.7.2.jar,cxf-rt-ws-policy-2.7.2.jar,neethi-3.0.2.jar,cxf-rt-bindings-soap-2.7.2.jar,cxf-rt-databinding-jaxb-2.7.2.jar,cxf-rt-transports-http-2.7.2.jar,cxf-api-2.7.2.jar,woodstox-core-asl-4.1.4.jar,stax2-api-3.1.1.jar,xmlschema-core-2.0.3.jar,geronimo-javamail_1.4_spec-1.7.1.jar,wsdl4j-1.6.2.jar,httpclient-4.1.jar,commons-logging-1.1.1.jar,commons-codec-1.4.jar,httpcore-4.2.3.jar,forms-1.1.0.jar,commons-io-2.4.jar,commons-lang-2.6.jar,activation-1.1-rev-1.jar,fast-md5-2.7.1.jar,image-manager-client-1.8.0-20150513.184428-1.jar,.
> 
> 
> And it is getting all of the XML stuff from the container (partial sample):
> 
> javax.xml.ws,version=2.1.0 from org.apache.felix.framework (0)<http://localhost:50043/system/console/bundles/0>
> javax.xml.ws.handler,version=2.1.0 from org.apache.felix.framework (0)<http://localhost:50043/system/console/bundles/0>
> javax.xml.ws.handler.soap,version=2.1.0 from org.apache.felix.framework (0)<http://localhost:50043/system/console/bundles/0>
> javax.xml.ws.http,version=2.1.0 from org.apache.felix.framework (0)<http://localhost:50043/system/console/bundles/0>
> 
> So I am stumped as to why this is happening. Any ideas on how I can get this to initialize?
Thanks in advance!
> 

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Mime
View raw message