{"record":{"id":"2e7fee6a07c50df0","repo":"hibernate/hibernate-orm","slug":"bean-validation-api-was-not-available-but-hibern","errorCode":null,"errorMessage":"Bean Validation API was not available, but 'hibernate.tooling.schema.apply_validation_constraints' was set to 'REQUIRED'","messagePattern":"Bean Validation API was not available, but 'hibernate\\.tooling\\.schema\\.apply_validation_constraints' was set to 'REQUIRED'","errorType":"exception","errorClass":"IntegrationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/beanvalidation/BeanValidationIntegrator.java","lineNumber":179,"sourceCode":"\t\t\tclassLoaderService.classForName( JAKARTA_BV_CHECK_CLASS );\n\t\t\treturn true;\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Used to validate the case when the Jakarta Validation API is not available.\n\t *\n\t * @param modes The requested validation modes.\n\t */\n\tprivate void validateMissingBeanValidationApi(Set<ValidationMode> modes, ValidationConstraintDdlInfluence constraintInfluence) {\n\t\tif ( modes.contains( ValidationMode.CALLBACK ) ) {\n\t\t\tthrow new IntegrationException( \"Jakarta Validation API was not available, but 'callback' validation was requested\" );\n\t\t}\n\t\tif ( constraintInfluence == ValidationConstraintDdlInfluence.REQUIRED ) {\n\t\t\tthrow new IntegrationException( \"Bean Validation API was not available, but '\"\n\t\t\t\t\t+ SchemaToolingSettings.APPLY_VALIDATION_CONSTRAINTS + \"' was set to 'REQUIRED'\" );\n\t\t}\n\t}\n\n\tprivate Class<?> loadTypeSafeActivatorClass(ClassLoaderService classLoaderService) {\n\t\ttry {\n\t\t\treturn classLoaderService.classForName( ACTIVATOR_CLASS_NAME );\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new HibernateException( \"Unable to load TypeSafeActivator class\", e );\n\t\t}\n\t}\n\n\tprivate record ActivationContextImpl(\n\t\t\tSet<ValidationMode> modes,\n\t\t\tValidationConstraintDdlInfluence constraintInfluence,\n\t\t\tMetadata metadata,\n\t\t\tSessionFactoryImplementor sessionFactory,","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/beanvalidation/BeanValidationIntegrator.java#L161-L197","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add jakarta.validation-api (and hibernate-validator) to the schema-tooling classpath","Or relax the setting to false/IGNORE if constraint-derived DDL is not actually required","Double-check the property name/value: REQUIRED is a strict contract, not a best-effort flag"],"exampleFix":"// before\nprops.put(\"hibernate.tooling.schema.apply_validation_constraints\", \"REQUIRED\"); // no BV API deployed\n\n// after (pick one)\nprops.put(\"hibernate.tooling.schema.apply_validation_constraints\", \"false\");\n// OR add jakarta.validation-api + hibernate-validator to the classpath and keep REQUIRED","handlingStrategy":"validation","validationCode":"if (\"REQUIRED\".equals(settings.get(\"hibernate.tooling.schema.apply_validation_constraints\"))) {\n    try {\n        Class.forName(\"jakarta.validation.Validation\");\n    } catch (ClassNotFoundException e) {\n        throw new IllegalStateException(\n            \"apply_validation_constraints=REQUIRED needs jakarta.validation-api on the classpath\", e);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    schemaExport.execute(...); // or SessionFactory build with schema generation\n} catch (IntegrationException e) {\n    if (e.getMessage().contains(\"apply_validation_constraints\"))\n        throw new IllegalStateException(\"Add the Bean Validation API or drop the REQUIRED setting\", e);\n    throw e;\n}","preventionTips":["Treat REQUIRED as a hard contract; run schema jobs with the full stack classpath","Prefer a dedicated, complete classpath for schema generation instead of a slimmed one"],"tags":["hibernate","bean-validation","schema-generation","missing-dependency","classpath"],"backgroundTag":"missing-validation-provider","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}