hibernate/hibernate-orm · error · HibernateException
Bytecode enhancement failed because no public, protected or
Error message
Bytecode enhancement failed because no public, protected or package-private default constructor was found for entity '{}' (private constructors don't work with runtime proxies) What it means
Error "Bytecode enhancement failed because no public, protected or package-private default constructor was found for entity '{}' (private constructors don't work with runtime proxies)" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/proxy/pojo/bytebuddy/ByteBuddyProxyFactory.java:106
final var hibernateProxy = internal.asHibernateProxy();
if ( hibernateProxy == null ) {
throw new HibernateException( "Produced proxy does not correctly implement HibernateProxy" );
}
return hibernateProxy;
}
/**
* This technically returns a HibernateProxy, but declaring that type as the return
* type for the newInstance() action triggers an implicit case of type pollution.
* We therefore declare it as PrimeAmongSecondarySupertypes, and require the
* invoker to perform the narrowing
*/
private PrimeAmongSecondarySupertypes getHibernateProxyInternal() throws HibernateException {
try {
return (PrimeAmongSecondarySupertypes) proxyClass.getConstructor().newInstance();
}
catch (NoSuchMethodException e) {
throw new HibernateException(
"Bytecode enhancement failed because no public, protected or package-private default constructor was found for entity '"
+ entityName + "' (private constructors don't work with runtime proxies)", e );
}
catch (Throwable t) {
throw new HibernateException( "Bytecode enhancement failed for entity '" + entityName + "'", t );
}
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Add a public, protected, or package-private no-arg constructor to the entity.
- Avoid private-only constructors on entities that need runtime proxies.
When it happens
Trigger: A dynamic instantiation (select new) target cannot be constructed.
Common situations: Using 'select new SomeClass(...)' where the class is missing or has no matching constructor.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/beb4c453e41b5080.
Report an issue: GitHub.