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!

Reply via email to