I try to embed axis2 (v. 1.5.1) and its dependencies in an osgi bundle using the maven-bundle-plugin. In my projects’ pom, I have the following tags:
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
In order that all axis2 dependencies (and transitive ones) are embedded into the final jar file. The jar file can be installed successfully in Felix, but the problem is that when another bundle try to use methods from a class of this jar, I get the exception:
javax.xml.stream.FactoryConfigurationError: Requested factory
com.ctc.wstx.stax.WstxInputFactory cannot be located.
Classloader =sun.misc.Launcher$AppClassLoader@9cab16
The com.ctc.wstx.stax.WstxInputFactory class is located in the woodstox wstx-asl artifact which is embedded into the jar, thus this exception should not be thrown.
I also tried to put this artifact into another bundle, but the same error occurs.
What is the issue here?
In this discussion they state that it is a class loader issue, but I can not find any solution.
Thank you
In the mailing list thread you mentioned, I already described one solution, which is not to embed StAX into the bundle, but to use OSGified versions of the StAX API and implementation (Woodstox).
If embedding StAX into the bundle is a hard requirement, then you need to add a bundle activator that calls the static setFactoryPerClassLoader method in org.apache.axiom.om.util.StAXUtils to set that property to false. At least this should work for any code (including Axis2) that uses StAX through Axiom, but you may still encounter the issue if there is code that interacts directly with StAX.