hibernate/hibernate-orm · error · HibernateException
Unable to check validity of passed ValidatorFactory
Error message
Unable to check validity of passed ValidatorFactory
What it means
When a ValidatorFactory is supplied to Hibernate (e.g. via the jakarta.persistence.validation.factory property), Hibernate reflectively calls TypeSafeActivator.validateSuppliedFactory to verify it. If that reflective invocation throws an InvocationTargetException whose target is not a HibernateException, the target is wrapped in this HibernateException — the supplied object itself exploded during the check, most often a linkage failure from mixed validation API versions.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/beanvalidation/BeanValidationIntegrator.java:67
* @param object The supposed ValidatorFactory instance
*/
public static void validateFactory(Object object) {
try {
// this direct usage of ClassLoader should be fine since the classes exist in the same jar
final var activatorClass =
BeanValidationIntegrator.class.getClassLoader()
.loadClass( ACTIVATOR_CLASS_NAME );
try {
final var validateMethod =
activatorClass.getMethod( VALIDATE_SUPPLIED_FACTORY_METHOD_NAME, Object.class );
try {
validateMethod.invoke( null, object );
}
catch (InvocationTargetException e) {
if ( e.getTargetException() instanceof HibernateException exception ) {
throw exception;
}
throw new HibernateException( "Unable to check validity of passed ValidatorFactory", e );
}
catch (IllegalAccessException e) {
throw new HibernateException( "Unable to check validity of passed ValidatorFactory", e );
}
}
catch (HibernateException e) {
throw e;
}
catch (Exception e) {
throw new HibernateException( "Could not locate method needed for ValidatorFactory validation", e );
}
}
catch (HibernateException e) {
throw e;
}
catch (Exception e) {
throw new HibernateException( "Could not locate TypeSafeActivator class", e );
}View on GitHub (pinned to fad1729dce)
Solutions
- Unwrap and read the nested cause (commonly NoClassDefFoundError or LinkageError) and remove the conflicting validation jar it names
- Align the whole stack on one namespace and one provider generation (e.g. hibernate-validator 8.x + jakarta.validation-api 3.x)
- Build the ValidatorFactory inside the same deployment/classloader as Hibernate
- Prefer letting Hibernate bootstrap its own factory: drop the supplied-factory property
Defensive patterns
Strategy: validation
Validate before calling
// refuse to boot with both validation namespaces present
static void assertSingleValidationNamespace() {
boolean javaxApi = present("javax.validation.Validation");
boolean jakartaApi = present("jakarta.validation.Validation");
if (javaxApi && jakartaApi)
throw new IllegalStateException(
"Both javax and jakarta validation APIs on the classpath; remove one before passing a ValidatorFactory");
}
static boolean present(String cn) {
try { Class.forName(cn, false, Thread.currentThread().getContextClassLoader()); return true; }
catch (ClassNotFoundException e) { return false; }
} Try / catch
try {
emf = Persistence.createEntityManagerFactory("pu", props); // props contain validation.factory
} catch (HibernateException e) {
Throwable root = e;
while (root.getCause() != null) root = root.getCause();
// root is often NoClassDefFoundError naming the conflicting validation jar
throw new IllegalStateException("Supplied ValidatorFactory failed validation check; cause: " + root, e);
} Prevention
- Run one consistent validation namespace/provider across all modules
- Build the factory you pass with the same classloader as the application
When it happens
Trigger: Passing a ValidatorFactory through persistence unit properties while the javax/jakarta validation API and provider jars on the classpath are inconsistent, so merely touching the factory triggers NoClassDefFoundError/LinkageError inside the reflective call; also seen under classloader domains that partially isolate the provider.
Common situations: Partial Spring Boot 2→3 / Java EE→Jakarta migrations leaving both javax.validation and jakarta.validation artifacts; a ValidatorFactory built by a different, incompatible classloader (app server vs WAR).
Related errors
- Could not locate method needed for ValidatorFactory validati
- Unable to locate TypeSafeActivator#activate method
- Multiple active MetadataBuilder definitions were discovered
- Validation failed for classes {} during {} time for groups [
- Could not locate TypeSafeActivator class
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/068e2a39c6eabd4d.
Report an issue: GitHub.