hibernate/hibernate-orm · error · ModelsException

Persistence unit lifecycle callback method not found

Error message

Persistence unit lifecycle callback method not found: %s (%s)

What it means

An XML-declared persistence-unit lifecycle callback names a method that does not exist on the listener class (or exists with no valid signature). The method-name element in orm.xml points at a missing/renamed method; update the declaration to match a real method.

Solutions

  1. Ensure the named callback method exists on the listener class with the required signature (void return, correct single parameter, accessible).

Example fix

Ensure the named callback method exists on the listener class with the required signature (void return, correct single parameter, accessible).
Defensive patterns

Strategy: validation

When it happens

Trigger: A JPA entity-listener or lifecycle callback violates the callback contract.

Common situations: Listener classes with missing lifecycle annotations, wrong method signatures, or multiple methods for the same event type.


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

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/models/spi/PersistenceUnitLifecycleEventHandler.java:146

			@Nonnull PersistenceUnitCallbackType callbackType,
			@Nonnull List<CallbackMethod> callbackMethods) {
		if ( lifecycleCallback != null ) {
			MethodDetails namedMethod = null;
			for ( var methodDetails : listenerClassDetails.getMethods() ) {
				if ( methodDetails.getName().equals( lifecycleCallback.getMethodName() ) ) {
					namedMethod = methodDetails;
					if ( hasValidSignature( methodDetails ) ) {
						checkDuplicate( listenerClassDetails, methodDetails, callbackType, callbackMethods );
						callbackMethods.add( new CallbackMethod( callbackType, methodDetails ) );
						return;
					}
				}
			}

			if ( namedMethod != null ) {
				validateSignature( listenerClassDetails, namedMethod, callbackAnnotation );
			}
			throw new ModelsException( "Persistence unit lifecycle callback method not found: "
										+ lifecycleCallback.getMethodName()
										+ " (" + listenerClassDetails.getClassName() + ")" );
		}
	}

	private static void validateSignature(
			@Nonnull ClassDetails listenerClassDetails,
			@Nonnull MethodDetails methodDetails,
			@Nonnull Class<? extends Annotation> callbackAnnotation) {
		if ( !hasValidSignature( methodDetails ) ) {
			throw new ModelsException( "Callback method '"
					+ methodDetails.getName() + "' annotated '@"
					+ callbackAnnotation.getSimpleName() + "' in '"
					+ listenerClassDetails.getClassName()
					+ "' must return void and have one parameter of type 'EntityAgent', 'EntityManager', or 'EntityManagerFactory'");
		}
	}

View on GitHub (pinned to fad1729dce)