hibernate/hibernate-orm · error · HibernateException

Bytecode enhancement failed for entity

Error message

Bytecode enhancement failed for entity '{}'

What it means

Wraps reflective instantiation failure while creating the proxy instance (proxyClass.getConstructor().newInstance): the default constructor was missing or threw. The faulty input is the generated proxy class for the entity; diagnose via the cause, typically a constructor access problem or an exception inside the proxy's initialization.

Solutions

  1. Inspect the cause of the ByteBuddy enhancement failure.
  2. Simplify the entity hierarchy or align bytecode library versions.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: A runtime precondition of the Hibernate API is violated.

Common situations: Occurs when application code or configuration does not satisfy the documented contract of the API being called.


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

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/proxy/pojo/bytebuddy/ByteBuddyProxyFactory.java:111

	}

	/**
	 * 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)