{"record":{"id":"441c409522640770","repo":"hibernate/hibernate-orm","slug":"unable-to-load-schema-schemaurl","errorCode":null,"errorMessage":"Unable to load schema [${schemaUrl}]","messagePattern":"Unable to load schema \\[(.+?)\\]","errorType":"exception","errorClass":"XmlInfrastructureException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/stax/LocalSchemaLocator.java","lineNumber":55,"sourceCode":"\t\tif ( url == null ) {\n\t\t\tthrow new XmlInfrastructureException( \"Unable to locate schema [\" + schemaResourceName + \"] via classpath\" );\n\t\t}\n\t\treturn url;\n\t}\n\n\tpublic static Schema resolveLocalSchema(String schemaName){\n\t\treturn resolveLocalSchema( resolveLocalSchemaUrl( schemaName ) );\n\t}\n\n\tpublic static Schema resolveLocalSchema(URL schemaUrl) {\n\t\ttry {\n\t\t\tfinal var schemaStream = schemaUrl.openStream();\n\t\t\ttry {\n\t\t\t\treturn SchemaFactory.newInstance( W3C_XML_SCHEMA_NS_URI )\n\t\t\t\t\t\t.newSchema( new StreamSource( schemaUrl.openStream() ) );\n\t\t\t}\n\t\t\tcatch ( Exception e ) {\n\t\t\t\tthrow new XmlInfrastructureException( \"Unable to load schema [\" + schemaUrl.toExternalForm() + \"]\", e );\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\ttry {\n\t\t\t\t\tschemaStream.close();\n\t\t\t\t}\n\t\t\t\tcatch ( IOException e ) {\n\t\t\t\t\tJAXB_LOGGER.problemClosingSchemaStream( e.toString() );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch ( IOException e ) {\n\t\t\tthrow new XmlInfrastructureException( \"Stream error handling schema url [\" + schemaUrl.toExternalForm() + \"]\" );\n\t\t}\n\t}\n}\n","sourceCodeStart":37,"sourceCodeEnd":71,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/stax/LocalSchemaLocator.java#L37-L71","documentation":"After successfully opening the schema URL, LocalSchemaLocator hands the stream to SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI).newSchema(...); any failure there is wrapped as XmlInfrastructureException 'Unable to load schema [url]'. The XSD stream was readable but could not be compiled into a javax.xml.validation.Schema — corrupt schema bytes or a broken JAXP parser configuration.","triggerScenarios":"XSD resource corrupted in the artifact (e.g. Maven resource filtering tokenized/mangled the .xsd text), or conflicting JAXP implementations (old xerces/xml-apis jars overriding the JDK parser) so SchemaFactory cannot instantiate a working validator; partially written hibernate-core jar.","commonSituations":"Resource filtering enabled for all files in a repackaged jar breaking binary/text XSDs; legacy xercesInternal/xml-apis 1.x on the classpath in old app-server stacks; antivirus or download corruption of the jar.","solutions":["Check dependency tree for xml-apis, xerces, xercesImpl and exclude old versions so the JDK parser is used","Disable Maven resource filtering for .xsd files (or filter only on specific extensions)","Verify the schema loads standalone: SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(new File(\"mapping.xsd\")) in a test","Re-download a pristine hibernate-core if the jar is damaged"],"exampleFix":"<!-- before (maven) -->\n<resources><resource><directory>src/main/resources</directory><filtering>true</filtering></resource></resources>\n\n<!-- after -->\n<resources><resource><directory>src/main/resources</directory><filtering>true</filtering><excludes><exclude>**/*.xsd</exclude></excludes></resource></resources>","handlingStrategy":"validation","validationCode":"try {\n    javax.xml.validation.SchemaFactory\n        .newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI)\n        .newSchema(new org.xml.sax.InputSource(new StringReader(\"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'/>\")));\n} catch (org.xml.sax.SAXException e) {\n    throw new IllegalStateException(\"JAXP parser configuration broken - check xerces/xml-apis conflicts\", e);\n}","typeGuard":null,"tryCatchPattern":"catch (XmlInfrastructureException e) {\n    throw new IllegalStateException(\"Cannot compile bundled XSD - likely corrupt resource or conflicting XML parser jars\", e);\n}","preventionTips":["Exclude legacy xerces/xml-apis artifacts from dependencies","Disable Maven resource filtering for .xsd files","Verify shipped hibernate-core jar checksums in the build"],"tags":["jaxp","xsd","classpath","dependency-conflict"],"backgroundTag":"xsd-schema-load-failed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}