hibernate/hibernate-orm · error · HibernateException

Bytecode enhancement failed for class '{originalClass}' (it

Error message

Bytecode enhancement failed for class '{originalClass}' (it might be due to the Java module system preventing Hibernate ORM from defining an enhanced class in the same package - in this case, the class should be opened and exported to Hibernate ORM)

What it means

Error "Bytecode enhancement failed for class '{originalClass}' (it might be due to the Java module system preventing Hibernate ORM from defining an enhanced class in the same package - in this case, the class should be opened and exported to Hibernate ORM)" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/ByteBuddyState.java:318

		public FieldAccessor.PropertyConfigurable getInterceptorFieldAccessor() {
			return interceptorFieldAccessor;
		}

		public DynamicType.Builder<?> appendIgnoreAlsoAtEnd(DynamicType.Builder<?> builder) {
			for ( var elementMatcher : toFullyIgnore ) {
				builder = builder.ignoreAlso( elementMatcher );
			}
			return builder;
		}
	}

	private static ClassLoadingStrategy<ClassLoader> resolveClassLoadingStrategy(Class<?> originalClass) {
		try {
			return ClassLoadingStrategy.UsingLookup.of( MethodHandles.privateLookupIn( originalClass, LOOKUP ) );
		}
		catch (Throwable e) {
			throw new HibernateException( "Bytecode enhancement failed for class '" + originalClass.getName()
					+ "' (it might be due to the Java module system preventing Hibernate ORM from defining an enhanced class in the same package"
					+ " - in this case, the class should be opened and exported to Hibernate ORM)", e );
		}
	}

	private static class FixedNamingStrategy extends NamingStrategy.AbstractBase {
		private final String className;

		public FixedNamingStrategy(String className) {
			this.className = className;
		}

		@Override
		protected String name(TypeDescription typeDescription) {
			return className;
		}
	}
}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Open and export the entity package to Hibernate ORM (module-info: 'opens com.acme.model to org.hibernate.orm.core') or move enhancement to build time.

Example fix

Open and export the entity package to Hibernate ORM (module-info: 'opens com.acme.model to org.hibernate.orm.core') or move enhancement to build time.

When it happens

Trigger: Bytecode enhancement, proxy creation, or lazy interception is applied to an incompatible class or configuration.

Common situations: Build-time enhancement with module-system restrictions, mismatched Hibernate versions between build and runtime, or hibernate.bytecode.provider=none with a model that needs proxies.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/6c8071bd208bde7f. Report an issue: GitHub.