{"record":{"id":"76e7890cd35d1c32","repo":"hibernate/hibernate-orm","slug":"could-not-open-url-stream-url","errorCode":null,"errorMessage":"Could not open url stream : ${url}","messagePattern":"Could not open url stream : (.+?)","errorType":"exception","errorClass":"XmlInfrastructureException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/stax/LocalXmlResourceResolver.java","lineNumber":143,"sourceCode":"\t\t\t\t\tJAXB_LOGGER.resolvedOnClasspath( systemID );\n\t\t\t\t}\n\t\t\t\treturn stream;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tprivate InputStream openUrlStream(XsdDescriptor xsdDescriptor) {\n\t\treturn openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( xsdDescriptor.getLocalResourceName() ) );\n\t}\n\n\tprivate InputStream openUrlStream(URL url) {\n\t\ttry {\n\t\t\treturn url.openStream();\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new XmlInfrastructureException( \"Could not open url stream : \" + url.toExternalForm(), e );\n\t\t}\n\t}\n\n\tprivate InputStream resolveInLocalNamespace(String path) {\n\t\ttry {\n\t\t\treturn resourceStreamLocator.locateResourceStream( path );\n\t\t}\n\t\tcatch ( Throwable t ) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tpublic static final DtdDescriptor MAPPING_DTD = new DtdDescriptor(\n\t\t\t\"www.hibernate.org/dtd/hibernate-mapping\",\n\t\t\t\"org/hibernate/hibernate-mapping-3.0.dtd\"\n\t);\n\n\tpublic static final DtdDescriptor ALTERNATE_MAPPING_DTD = new DtdDescriptor(","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/stax/LocalXmlResourceResolver.java#L125-L161","documentation":"While parsing a mapping document, LocalXmlResourceResolver resolves referenced schemas (imports, systemIds, namespaces) and opens them via openUrlStream; an IOException from url.openStream() becomes XmlInfrastructureException 'Could not open url stream : <url>'. The resolver found a URL for the schema but could not open its stream — usually a bundled-local schema missing from the classpath, forcing a remote/unreachable URL.","triggerScenarios":"A mapping document that references a schema Hibernate cannot satisfy from its bundled XSDs (custom schemaLocation hints, unusual namespace version), so resolution lands on a URL that fails to open — offline environment, unreachable host, or a resource locator returning a dead URL.","commonSituations":"Custom orm.xml/schemaLocation attributes pointing at company-internal HTTP schemas; air-gapped deployments where the resolver falls back to the network; classpath missing hibernate's XSDs so every lookup goes remote.","solutions":["Remove custom xsi:schemaLocation / schema hints from mapping documents so Hibernate resolves its bundled local XSDs (LocalXmlResourceResolver resolves hibernate namespaces locally first)","Ensure hibernate-core with its org/hibernate/xsd/** resources is on the classpath (see error 389)","If schemas genuinely live remotely, verify reachability from the deploy host and configure proxies","For custom schemas, register them via an EntityResolver / XMLCatalog or package them as classpath resources"],"exampleFix":"<!-- before -->\n<hibernate-mapping xmlns=\"http://www.hibernate.org/xsd/hibernate-mapping\"\n  xsi:schemaLocation=\"http://www.hibernate.org/xsd/hibernate-mapping http://www.hibernate.org/dtd/hibernate-mapping-4.0.xsd\">\n\n<!-- after: let Hibernate resolve its bundled XSD -->\n<hibernate-mapping xmlns=\"http://www.hibernate.org/xsd/hibernate-mapping\">","handlingStrategy":"validation","validationCode":"// CI check: parse all mapping documents fully offline; if any schema resolution goes remote, fail\n// and inspect xsi:schemaLocation attributes before shipping:\n// grep -r \"schemaLocation\" src/main/resources -l  should only list Hibernate-standard namespaces","typeGuard":null,"tryCatchPattern":"catch (XmlInfrastructureException e) {\n    throw new IllegalStateException(\"Could not open stream for a resolved schema URL - check custom schemaLocation hints and network access\", e);\n}","preventionTips":["Do not override xsi:schemaLocation with remote URLs in mapping files","Test bootstrap in an offline CI stage to catch remote schema fallbacks","Keep hibernate-core's bundled XSDs intact so local resolution always wins"],"tags":["xsd","resolver","network","bootstrap"],"backgroundTag":"schema-resolution-failed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}