Classifying this as a bug because it effectively prevents from using Hibernate ORM in a modular environment beyond the very simple use cases, even though we did some work to make Hibernate ORM usable, as an automatic module.
In short, when a user deploys an application in the module path, they have no choice but to only ever use modules. As a result, they will use Hibernate ORM as an automatic module, and more importantly they will also use other libraries, such as Hibernate Search, as automatic modules. They simply cannot leave those in the classpath: they couldn't access them.
The problem is, as soon as other libraries are in the module path, Hibernate ORM seems unable to detect their declared services.
I investigated a bit, and the problem is not that automatic modules cannot declare services or use services from other modules (that works just fine), it's really only Hibernate ORM that fails to load the modules. You can see this live in this reproducer: https://github.com/yrodiere/java-module-sandbox/
Just clone it, set JDK11 as your default JDK, and run mvn clean install.
You'll see this in the logs:
What's important here are the information below the "RESULT" lines:
The first one demonstrates that an automatic module can load services provided by another automatic module. I created custom modules just for that.
The second one demonstrates that an automatic module can load services provided by Hibernate Search used as an automatic module.
The third, fourth and fifth ones demonstrate that Hibernate ORM does not see Hibernate Search services when booted as an automatic module. Interestingly, libraries that stay in the classpath (because the application does not use them directly) have their services correctly detected.
I think the root cause of the problem may have something to do with how ORM uses an aggregated classloader.
Indeed, I've also experienced NoClassDefFoundError in my modular application, and I had to declare dependencies from my application to other modules such as java.xml.bind, even though my application doesn't use those: only Hibernate ORM does. There is something fishy here...