hibernate/hibernate-orm · error · IntegrationException

Error activating Bean Validation integration

Error message

Error activating Bean Validation integration

What it means

The reflective call into TypeSafeActivator.activate(ActivationContext) threw: if the target exception is not already a HibernateException it is wrapped in this IntegrationException. The real reason lives in the cause chain — most commonly the default ValidatorFactory could not be bootstrapped (missing provider, broken validation.xml, or incompatible javax/jakarta validation versions).

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/beanvalidation/BeanValidationIntegrator.java:144

	}

	private void callActivateMethod(ClassLoaderService classLoaderService, ActivationContext activationContext)
			throws NoSuchMethodException {
		final var activateMethod =
				loadTypeSafeActivatorClass( classLoaderService )
						.getMethod( ACTIVATE_METHOD_NAME, ActivationContext.class );
		try {
			activateMethod.invoke( null, activationContext );
		}
		catch (InvocationTargetException e) {
			final var targetException = e.getTargetException();
			throw targetException instanceof HibernateException exception
					? exception
					: new IntegrationException( "Error activating Bean Validation integration",
							targetException );
		}
		catch (Exception e) {
			throw new IntegrationException( "Error activating Bean Validation integration", e );
		}
	}

	private static Set<ValidationMode> getValidationModes(ServiceRegistry serviceRegistry) {
		final var settings =
				serviceRegistry.requireService( ConfigurationService.class )
						.getSettings();
		Object modeSetting = settings.get( JAKARTA_MODE_PROPERTY );
		if ( modeSetting == null ) {
			modeSetting = settings.get( MODE_PROPERTY );
		}
		return ValidationMode.parseValidationModes( modeSetting );
	}

	private boolean isBeanValidationApiAvailable(ClassLoaderService classLoaderService) {
		try {
			classLoaderService.classForName( JAKARTA_BV_CHECK_CLASS );
			return true;

View on GitHub (pinned to fad1729dce)

Solutions

  1. Unwrap the IntegrationException and read the root cause — it names the actual bootstrap failure
  2. Add a matching provider: org.hibernate.validator:hibernate-validator plus jakarta.validation-api of the generation your Hibernate expects
  3. If entity validation is not wanted, set validation mode NONE explicitly instead of leaving AUTO/CALLBACK
  4. Alternatively pass a known-good factory via jakarta.persistence.validation.factory
Defensive patterns

Strategy: validation

Validate before calling

// probe the Bean Validation stack independently before Hibernate integrates it
try (var probe = jakarta.validation.Validation.buildDefaultValidatorFactory()) {
    probe.getValidator().validate(new Object()); // forces provider bootstrap
} catch (Throwable t) {
    throw new IllegalStateException(
        "Bean Validation cannot bootstrap on its own; fix this before starting Hibernate", t);
}

Try / catch

try {
    sessionFactory = new Configuration().buildSessionFactory();
} catch (IntegrationException e) {
    Throwable root = e;
    while (root.getCause() != null) root = root.getCause();
    throw new IllegalStateException("Bean Validation activation failed, root cause: " + root, e);
}

Prevention

When it happens

Trigger: SessionFactory startup with validation mode CALLBACK or AUTO while the underlying ValidatorFactory cannot be created: no Bean Validation provider on the classpath, a failing META-INF/validation.xml, or an API/provider version mismatch touched during activate().

Common situations: Adding hibernate-core without hibernate-validator; Jakarta migrations where a javax-based Spring LocalValidatorFactoryBean or legacy provider is still present; malformed validation.xml copied between projects.

Related errors


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