Reputation: 65
I am trying to use the fuelsdk in an osgi environment in AEM. I am getting this error -
java.lang.ClassCastException: com.sun.xml.internal.ws.client.sei.SEIStub cannot be cast to org.apache.cxf.frontend.ClientProxy
This is because OSGi loads the system bundle before the bundle in which fuelsdk's dependency has been embedded. The bundle gets resolved; this error is during run time.
How can I force the OSGi classloader to pick org.apache.cxf.frontend.ClientProxy instead of com.sun.xml.internal.ws.client.sei.SEIStub at run time ?
Can I use the combination of 'uses' directive ; and/or import/export packages ?
I have been suggested to create the client using -
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(HelloWorld.class);
factory.setAddress("http://localhost:9000/helloWorld");
soapClient = (Client) factory.create();
I would like to know which class should I use in factory.setServiceClass();
and
which address should I use in factory.setAddress( ) ; is it the endpoint address ? -- https://webservice.s6.exacttarget.com/Service.asmx
Help is highly appreciated Thanks
Upvotes: 1
Views: 3489
Reputation: 1712
You could try updating the org.osgi.framework.bootdelegation
property in <your installation>/crx-quickstart/conf/sling.properties
org.osgi.framework.bootdelegation= org.apache.cxf.*, ${org.apache.sling.launcher.bootdelegation}
You can read more about sling.properties
here
UPDATE - You could enforce your package to use the custom bundle than the Java one, to do that you will have to wrap your org.apache.cxf.* packages in a custom bundle with additional properties -
org.apache.cxf.*
packagesIn the custom bundle POM, configure maven-bundle plugin as (notice Export-Package with ;myidentifier="true";mandatory:="myidentifier"
, give a proper identifier name here and you may also have to do this at package level if * doesn't work)
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Export-Package>
org.apache.cxf.*;myidentifier="true";mandatory:="myidentifier"
</Export-Package>
<Private-Package>
</Private-Package>
<Import-Package>
*
</Import-Package>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Activator>${project.artifactId}.Activator</Bundle-Activator>
<Include-Resource>
{maven-resources}
</Include-Resource>
<Embed-Dependency>
<!-- list of jar's to embed, exposing the Exporting packages. Comma separated-->
</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
Where ever you need to use these packages you will have to update the maven-bundle plugin and specify import explicitly -
<Import-Package>org.apache.cxf.*;myidentifier="true",*</Import-Package>
We are using this approach to use higher version on few bundles that come packaged with AEM like Guava, AEM comes with Guava 15 while we expose Guava 18 without interfaring with system's usage of Guava 15
You can read more about it here
Upvotes: 1