{"record":{"id":"6c072bfb3cb88dbd","repo":"hibernate/hibernate-orm","slug":"unable-to-build-configuration-xml-jaxbcontext","errorCode":null,"errorMessage":"Unable to build configuration.xml JAXBContext","messagePattern":"Unable to build configuration\\.xml JAXBContext","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/ConfigurationBinder.java","lineNumber":62,"sourceCode":"\t\tfinal XMLEventReader reader = new ConfigurationEventReader( staxEventReader, xmlEventFactory );\n\t\tfinal JaxbPersistenceImpl bindingRoot = jaxb(\n\t\t\t\treader,\n\t\t\t\tConfigXsdSupport.latestDescriptor().getSchema(),\n\t\t\t\tjaxbContext(),\n\t\t\t\torigin\n\t\t);\n\t\t//noinspection unchecked\n\t\treturn new Binding<>( (X) bindingRoot, origin );\n\t}\n\n\t@Internal\n\tpublic JAXBContext jaxbContext() {\n\t\tif ( jaxbContext == null ) {\n\t\t\ttry {\n\t\t\t\tjaxbContext = JAXBContext.newInstance( JaxbPersistenceImpl.class );\n\t\t\t}\n\t\t\tcatch (JAXBException e) {\n\t\t\t\tthrow new ConfigurationException( \"Unable to build configuration.xml JAXBContext\", e );\n\t\t\t}\n\t\t}\n\t\treturn jaxbContext;\n\t}\n}\n","sourceCodeStart":44,"sourceCodeEnd":68,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/ConfigurationBinder.java#L44-L68","documentation":"ConfigurationBinder could not create the JAXBContext used to read configuration.xml/persistence.xml: JAXBContext.newInstance(JaxbPersistenceImpl.class) threw JAXBException, wrapped in ConfigurationException. On modern JDKs the dominant cause is a missing JAXB runtime - java.xml.bind was removed from the JDK in Java 11 - or a broken/conflicting JAXB implementation on the classpath.","triggerScenarios":"Running Hibernate's native XML configuration bootstrapping on JDK 11+ without jakarta/javax XML bind API and a runtime (e.g. glassfish jaxb-runtime) on the classpath; or with mismatched jaxb-api/jaxb-impl versions fighting each other.","commonSituations":"Apps upgraded from JDK 8 to 11/17 without adding explicit JAXB dependencies; slimmed runtimes (jlink, some app servers) stripping JAXB; multiple jaxb-runtime versions via transitive deps.","solutions":["Add the JAXB API and a runtime matching your Hibernate version's namespace (jakarta.xml.bind-api + org.glassfish.jaxb:jaxb-runtime for jakarta-flavored Hibernate 6.2+; javax versions for older lines)","Verify only one jaxb runtime resolves: mvn dependency:tree | grep -i jaxb (or gradle equivalent)","Confirm the fix with a trivial Class.forName check on the JAXBContext class before bootstrapping","If you do not use configuration.xml/persistence.xml at all, build Configuration/Metadata programmatically to bypass the XML binder"],"exampleFix":"<!-- before: JDK 11+, no JAXB on classpath -> ConfigurationException -->\n<dependencies>\n    <dependency>org.hibernate.orm:hibernate-core:6.x</dependency>\n</dependencies>\n\n<!-- after -->\n<dependencies>\n    <dependency>org.hibernate.orm:hibernate-core:6.x</dependency>\n    <dependency>\n        <groupId>jakarta.xml.bind</groupId>\n        <artifactId>jakarta.xml.bind-api</artifactId>\n    </dependency>\n    <dependency>\n        <groupId>org.glassfish.jaxb</groupId>\n        <artifactId>jaxb-runtime</artifactId>\n    </dependency>\n</dependencies>","handlingStrategy":"validation","validationCode":"// verify a JAXB runtime is present before bootstrapping XML config\ntry {\n    Class.forName(\"jakarta.xml.bind.JAXBContext\");   // Hibernate 6.2+\n    // Class.forName(\"javax.xml.bind.JAXBContext\");  // older lines\n} catch (ClassNotFoundException e) {\n    throw new IllegalStateException(\"No JAXB runtime on JDK 11+: add jakarta.xml.bind-api + jaxb-runtime\", e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    configurationBinder.jaxbContext();\n} catch (ConfigurationException e) {\n    // almost always a missing/conflicting JAXB runtime: fix the classpath, not the code\n    throw new IllegalStateException(\"Add a JAXB runtime to the application classpath\", e);\n}","preventionTips":["Add explicit JAXB API + runtime dependencies on JDK 11+","Keep exactly one jaxb-runtime version in the dependency tree","Re-check dependencies after JDK or Hibernate upgrades"],"tags":["hibernate","jaxb","jdk-11","classpath","configuration"],"backgroundTag":"missing-jaxb-runtime","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}