Problems with Hibernate ORM + Equinox + Java 11

Hello,

we are using Hibernate ORM with OSGi on the eclipse Equinox platform (that means we use Equinox feature.xml and product definitions for our products). Until now, all our products that required Hibernate used Java 9 (or older), so this hasn’t been a problem. But now I want to update our products to run with Java 11 and I run into issues with javax.bind.xml. It’s the old problem that it isn’t part of the JRE anymore - we “fixed” the problem in Java 9 by adding --add-modules java.xml.bind but now we need a new solution.

My current solution is the most recommended one: I add jaxb-api, jaxb-core and jaxb-impl as dependencys into my feature. BUT. This alone doesn’t fix the problem - I still have to add -Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory to my vm arguments (this is okay, but if you have a suggestion so that I can omit that, I’d be grateful).

But to use com.sun.xml.bind.v2.ContextFactory, I also have to import the package com.sun.xml.bind.v2 in my bundle that uses hibernate, because the Hibernate Classloader can’t find the class on its own! This is problematic, because the relation is in no way obvious and a few months from now, the package import might be removed because “obviously” the plugin doesn’t need the import.

Is there a way to make the hibernate classloader able to load the class without this ugly hack?

I think you’d be better off asking this to the OSGi / Equinox community. This is nothing really Hibernate-specific.

Sorry I don’t have a better answer.

Perhaps @brmeyer might have a better answer…

Hello @peterjeschke

I work with Karaf (that can work both with Felix and Equinox) and Red Hat Fuse (which is a supported version of Karaf + multitude of other projects like Camel and CXF).

Fuse itself wasn’t (yet) certified on JDK 11 (there’s a plan to do it for Fuse 7.9 release) and I don’t have a straight answer for you. But I’ll definitely check the JAXB usage in OSGi runtime with JDK11 soon.

The problem you’ve described does’t look related to HIbernate itself - JAXB packages (both the API and implementation) should be available through system bundle and ideally these packages should be listed in org.osgi.framework.bootdelegation OSGi framework property.

Did you try running your application on upstream Karaf 4.2.11 or 4.3.0? Remember, that it can be use Equinox as underlying OSGi Core implementation.

regards
Grzegorz Grzybek