hibernate/hibernate-orm · error · RuntimeException
Couldn't load or define class [{className}]
Error message
Couldn't load or define class [{className}] What it means
Error "Couldn't load or define class [{className}]" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/ByteBuddyState.java:200
if ( result.getClassLoader() == referenceClass.getClassLoader() ) {
return result;
}
}
catch (ClassNotFoundException e) {
// Ignore
}
try {
return make( makeClassFunction.apply( byteBuddy, new FixedNamingStrategy( className ) ) )
.load( referenceClass.getClassLoader(),
resolveClassLoadingStrategy( referenceClass ) )
.getLoaded();
}
catch (LinkageError e) {
try {
return referenceClass.getClassLoader().loadClass( className );
}
catch (ClassNotFoundException ex) {
throw new RuntimeException( "Couldn't load or define class [" + className + "]", e );
}
}
}
private Class<?> load(Class<?> referenceClass, TypeCache<TypeCache.SimpleKey> cache,
TypeCache.SimpleKey cacheKey, Function<ByteBuddy, DynamicType.Builder<?>> makeProxyFunction) {
return cache.findOrInsert(
referenceClass.getClassLoader(),
cacheKey,
() -> make( makeProxyFunction.apply( byteBuddy ) )
.load( referenceClass.getClassLoader(),
resolveClassLoadingStrategy( referenceClass ) )
.getLoaded(),
cache
);
}
public Unloaded<?> make(Function<ByteBuddy, DynamicType.Builder<?>> makeProxyFunction) {View on GitHub (pinned to fad1729dce)
Solutions
- 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/7841416ff858677f.
Report an issue: GitHub.