{"record":{"id":"c4ef74ad7bc83a41","repo":"hibernate/hibernate-orm","slug":"jakarta-validation-api-was-not-available-but-cal","errorCode":null,"errorMessage":"Jakarta Validation API was not available, but 'callback' validation was requested","messagePattern":"Jakarta Validation API was not available, but 'callback' validation was requested","errorType":"exception","errorClass":"IntegrationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/beanvalidation/BeanValidationIntegrator.java","lineNumber":176,"sourceCode":"\n\tprivate boolean isBeanValidationApiAvailable(ClassLoaderService classLoaderService) {\n\t\ttry {\n\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,","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/beanvalidation/BeanValidationIntegrator.java#L158-L194","documentation":"At integration time Hibernate detected that the Jakarta Validation API is absent from the classpath, but the persistence unit requested CALLBACK validation (validation-mode in persistence.xml or the jakarta.persistence.validation.mode setting). Since Hibernate cannot honor callbacks without the API, it fails fast during SessionFactory construction.","triggerScenarios":"persistence.xml with <validation-mode>CALLBACK</validation-mode> or the property jakarta.persistence.validation.mode=callback while jakarta.validation:jakarta.validation-api is not on the runtime classpath.","commonSituations":"Dependencies slimmed to scope provided but missing at runtime; persistence.xml templates copied from a Java EE app into plain Java SE; fat-jar minimization (ProGuard, shade rules) stripping 'unused' validation jars.","solutions":["Add jakarta.validation:jakarta.validation-api plus a provider such as hibernate-validator","If entity validation is unwanted, change validation mode to NONE","Verify the runtime classpath (docker image, assembly, shaded jar) actually contains the API jar"],"exampleFix":"// before: persistence.xml requests callbacks, classpath lacks the API\n<validation-mode>CALLBACK</validation-mode>\n\n// after: add API + provider to the runtime classpath (pom.xml)\n<dependency>\n  <groupId>jakarta.validation</groupId>\n  <artifactId>jakarta.validation-api</artifactId>\n  <version>3.0.2</version>\n</dependency>\n<dependency>\n  <groupId>org.hibernate.validator</groupId>\n  <artifactId>hibernate-validator</artifactId>\n  <version>8.0.1.Final</version>\n</dependency>","handlingStrategy":"validation","validationCode":"// check the API is really on the runtime classpath before requesting CALLBACK\ntry {\n    Class.forName(\"jakarta.validation.ValidatorFactory\", false,\n                  Thread.currentThread().getContextClassLoader());\n} catch (ClassNotFoundException e) {\n    // either add jakarta.validation-api + provider, or change validation-mode to NONE\n    throw new IllegalStateException(\"CALLBACK requested but jakarta.validation-api is missing\", e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    emf = Persistence.createEntityManagerFactory(\"pu\");\n} catch (IntegrationException e) {\n    if (e.getMessage().contains(\"'callback' validation was requested\"))\n        throw new IllegalStateException(\"Add jakarta.validation-api + a provider, or set validation-mode NONE\", e);\n    throw e;\n}","preventionTips":["Keep validation-mode and the actual classpath in sync in every environment","Include validation jars in runtime images, not just compile scope"],"tags":["hibernate","bean-validation","missing-dependency","validation-mode","classpath"],"backgroundTag":"missing-validation-provider","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}