{"record":{"id":"26ba2311f2051a93","repo":"hibernate/hibernate-orm","slug":"unable-to-build-orm-xml-jaxbcontext","errorCode":null,"errorMessage":"Unable to build orm.xml JAXBContext","messagePattern":"Unable to build orm\\.xml JAXBContext","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/MappingBinder.java","lineNumber":211,"sourceCode":"\t\tif ( hbmJaxbContext == null ) {\n\t\t\ttry {\n\t\t\t\thbmJaxbContext = JAXBContext.newInstance( JaxbHbmHibernateMapping.class );\n\t\t\t}\n\t\t\tcatch (JAXBException e) {\n\t\t\t\tthrow new ConfigurationException( \"Unable to build hbm.xml JAXBContext\", e );\n\t\t\t}\n\t\t}\n\t\treturn hbmJaxbContext;\n\t}\n\n\t@Internal\n\tpublic JAXBContext mappingJaxbContext() {\n\t\tif ( entityMappingsJaxbContext == null ) {\n\t\t\ttry {\n\t\t\t\tentityMappingsJaxbContext = JAXBContext.newInstance( JaxbEntityMappingsImpl.class );\n\t\t\t}\n\t\t\tcatch (JAXBException e) {\n\t\t\t\tthrow new ConfigurationException( \"Unable to build orm.xml JAXBContext\", e );\n\t\t\t}\n\t\t}\n\t\treturn entityMappingsJaxbContext;\n\t}\n}\n","sourceCodeStart":193,"sourceCodeEnd":217,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/MappingBinder.java#L193-L217","documentation":"A ConfigurationException thrown when JAXBContext.newInstance(JaxbEntityMappingsImpl.class) fails while Hibernate prepares to bind orm.xml (JPA mapping) documents. As with the hbm variant, the wrapped JAXBException means the JAXB runtime could not be created — a classpath/JAXB-provider problem, independent of your mapping content.","triggerScenarios":"Any bootstrap that processes an orm.xml: missing jakarta.xml.bind runtime on JDK 11+, mixed javax/jakarta JAXB artifacts, a JAXB provider (e.g. EclipseLink MOXy) registered via META-INF/services that cannot handle Hibernate's generated classes, or shading that strips provider metadata.","commonSituations":"Migrating an app to Jakarta EE 9+ namespaces while an old javax JAXB jar remains; deploying into containers that provide their own JAXB; uber-jar builds dropping META-INF/services/jakarta.xml.bind.JAXBContext.","solutions":["Add jakarta.xml.bind-api + org.glassfish.jaxb:jaxb-runtime aligned with your Hibernate version","Audit the dependency tree and exclude javax.xml.bind:javax.xml.bind-api, com.sun.xml.bind, or MOXy artifacts that hijack the provider","If shading, preserve META-INF/services entries and the whole org.glassfish.jaxb package"],"exampleFix":"// quick probe to run before bootstrap\nClass.forName(\"jakarta.xml.bind.JAXBContext\");\nJAXBContext.newInstance(org.hibernate.boot.jaxb.internal.MappingBinder.class.getModule(), Object.class); // smoke test","handlingStrategy":"validation","validationCode":"try {\n    jakarta.xml.bind.JAXBContext.newInstance(org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl.class);\n} catch (jakarta.xml.bind.JAXBException e) {\n    throw new IllegalStateException(\"JAXB runtime unusable - fix classpath before bootstrap\", e);\n}","typeGuard":null,"tryCatchPattern":"catch (ConfigurationException e) {\n    if (e.getCause() instanceof jakarta.xml.bind.JAXBException) {\n        throw new IllegalStateException(\"JAXB runtime conflict while building orm.xml context - audit dependency:tree\", e);\n    }\n    throw e;\n}","preventionTips":["Pin exactly one JAXB runtime artifact across the project","If an app server provides JAXB, verify the provided version works before deploying","Include an orm.xml in test fixtures so JAXB context creation is exercised in CI"],"tags":["jaxb","classpath","orm-xml","bootstrap","dependency-conflict"],"backgroundTag":"jaxb-runtime-missing","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}