Using Hibernate ORM with JDK 11

Posted by    |       Hibernate ORM

JDK 11 is almost there and you might want to start testing your applications with it.

Your applications use Hibernate technologies? It shouldn’t be a problem but here are some important information.

Hibernate technologies and JDK 11 support

We started testing the Hibernate technologies with JDK 11 very early so we have some good news: Hibernate ORM (5.3.3+), Hibernate Search (5.10.4+) and Hibernate Validator (6.0.12+) can be used with JDK 11.

Note that, for now, even though we define automatic module names, running as Jigsaw modules is not fully tested and not expected to work.

A few quirks with ORM though

While Hibernate ORM 5.3 supports (and is tested with) JDK 11, there are a few things you need to tweak while waiting for Hibernate ORM 5.4.

JAXB dependency

JAXB is not provided by the JDK anymore so you need an external dependency for it:


These dependencies will be added in Hibernate ORM 5.4.

ByteBuddy experimental support

When using ORM with JDK 11, you might end up with the following exception coming from ByteBuddy:

Caused by: org.hibernate.bytecode.enhance.spi.EnhancementException: Failed to enhance class org.hibernate.jpa.test.enhancement.TestLazyPropertyOnPreUpdate
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.enhance(
        at org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner$2.loadClass(
        ... 40 more
Caused by: java.lang.UnsupportedOperationException
        at net.bytebuddy.jar.asm.ClassVisitor.visitNestMemberExperimental(
        at net.bytebuddy.jar.asm.ClassReader.accept(
        at net.bytebuddy.jar.asm.ClassReader.accept(
        at net.bytebuddy.pool.TypePool$Default.parse(

This is due to ASM (the component used by ByteBuddy to manipulate the bytecode) only supporting some JDK 11 features as experimental. ByteBuddy does the same and you need a specific flag to enable the support of these features.

To get everything in order, you need to add the following flag to your JVM: -Dnet.bytebuddy.experimental=true.

Hopefully, ASM 7 will be released soon.

Feedback, issues, ideas?

To get in touch, use the usual channels:

Back to top