It is often an issue if a package is available in a bundle and also in the bpot classpath (JDK). It is even a bigger issue if that package is wired from another JDK package and also from a bundle directly. In your case the problem is the following:
- javax.xml.transform.stax is available only on the boot classpath (JDK) so hibernate.core wires to that package.
- As javax.xml.transform.stax comes from the boot classpath, it can wire to another package on the boot classpath. It needs javax.xml.stream so it will wire to the package that comes from JDK
We have the chain:
hibernate.core -> javax.xml.transform.stax -> javax.xml.stream
On the other hand, hibernate.core wires to javax.xml.stream directly. Probably it even uses a version in the Import-Package section so it cannot wire to the package that comes from JDK.
We have the chain:
hibernate.core -> javax.xml.stream
This generates a conflict. As hibernate.core uses the javax.xml.stream API with the help of javax.xml.transform.stax, hibernate.core and javax.xml.transform.stax should use the same classes of javax.xml.stream. However, they do not.
You have a couple of options to solve your problem:
You can install a bundle that contains javax.xml.transform.stax package. That package will be able to wire to the javax.xml.stream package that comes from the bundle and also hibernate.core can wire to the bundle that contains javax.xml.transform.stax. You can pray that the wirings will be always OK.
In my experience, the wires are good after the framework is started. As the package versions are higher in the bundles, they will be preferred when the package is imported from other bundles. However, when the bundles are updated and refreshed at runtime, the wiring often goes wrong. I do not know why, it just happens.
To avoid every issue, I normally exclude those packages from the boot classpath that are also available in bundles.
Your next issue might be that these APIs often use factory classes. When someone uses such a factory, the classloader of the factory class must see the implementation classes, too. I created a bundle that contains all of the xmlcommons packages. It contains all of the xml-apis classes and implementation for them (xerces, xalan, etc). It might be helpful for you. If this bundle solves your problem, please let me know. In that case, I will take the time finally to collect all necessary data (licensing into the pom, sources) and release it to maven-central so it can help others as well.