hibernate/hibernate-orm · error · IntegrationException

Bean Validation API was not available, but 'hibernate.toolin

Error message

Bean Validation API was not available, but 'hibernate.tooling.schema.apply_validation_constraints' was set to 'REQUIRED'

What it means

Companion check to the missing-callback error, but for tooling: hibernate.tooling.schema.apply_validation_constraints was set to REQUIRED, which orders Hibernate to apply Bean Validation constraints to generated DDL. Without the Bean Validation API on the classpath that is impossible, so bootstrap fails immediately.

Source

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

			classLoaderService.classForName( JAKARTA_BV_CHECK_CLASS );
			return true;
		}
		catch (Exception e) {
			return false;
		}
	}

	/**
	 * Used to validate the case when the Jakarta Validation API is not available.
	 *
	 * @param modes The requested validation modes.
	 */
	private void validateMissingBeanValidationApi(Set<ValidationMode> modes, ValidationConstraintDdlInfluence constraintInfluence) {
		if ( modes.contains( ValidationMode.CALLBACK ) ) {
			throw new IntegrationException( "Jakarta Validation API was not available, but 'callback' validation was requested" );
		}
		if ( constraintInfluence == ValidationConstraintDdlInfluence.REQUIRED ) {
			throw new IntegrationException( "Bean Validation API was not available, but '"
					+ SchemaToolingSettings.APPLY_VALIDATION_CONSTRAINTS + "' was set to 'REQUIRED'" );
		}
	}

	private Class<?> loadTypeSafeActivatorClass(ClassLoaderService classLoaderService) {
		try {
			return classLoaderService.classForName( ACTIVATOR_CLASS_NAME );
		}
		catch (Exception e) {
			throw new HibernateException( "Unable to load TypeSafeActivator class", e );
		}
	}

	private record ActivationContextImpl(
			Set<ValidationMode> modes,
			ValidationConstraintDdlInfluence constraintInfluence,
			Metadata metadata,
			SessionFactoryImplementor sessionFactory,

View on GitHub (pinned to fad1729dce)

Solutions

  1. Add jakarta.validation-api (and hibernate-validator) to the schema-tooling classpath
  2. Or relax the setting to false/IGNORE if constraint-derived DDL is not actually required
  3. Double-check the property name/value: REQUIRED is a strict contract, not a best-effort flag

Example fix

// before
props.put("hibernate.tooling.schema.apply_validation_constraints", "REQUIRED"); // no BV API deployed

// after (pick one)
props.put("hibernate.tooling.schema.apply_validation_constraints", "false");
// OR add jakarta.validation-api + hibernate-validator to the classpath and keep REQUIRED
Defensive patterns

Strategy: validation

Validate before calling

if ("REQUIRED".equals(settings.get("hibernate.tooling.schema.apply_validation_constraints"))) {
    try {
        Class.forName("jakarta.validation.Validation");
    } catch (ClassNotFoundException e) {
        throw new IllegalStateException(
            "apply_validation_constraints=REQUIRED needs jakarta.validation-api on the classpath", e);
    }
}

Try / catch

try {
    schemaExport.execute(...); // or SessionFactory build with schema generation
} catch (IntegrationException e) {
    if (e.getMessage().contains("apply_validation_constraints"))
        throw new IllegalStateException("Add the Bean Validation API or drop the REQUIRED setting", e);
    throw e;
}

Prevention

When it happens

Trigger: Setting hibernate.tooling.schema.apply_validation_constraints=REQUIRED (or APPLY_VALIDATION_CONSTRAINTS) in the absence of jakarta.validation-api, typically in projects focused on hbm2ddl schema generation that stripped validation dependencies.

Common situations: Schema-tooling pipelines copying settings from documentation that assumes the full Jakarta stack; minimal Docker images trimming jars; CI schema-export jobs with a reduced classpath.

Related errors


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