hibernate/hibernate-orm · error · XmlInfrastructureException
Could not open url stream : ${url}
Error message
Could not open url stream : ${url} What it means
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.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/stax/LocalXmlResourceResolver.java:143
JAXB_LOGGER.resolvedOnClasspath( systemID );
}
return stream;
}
}
return null;
}
private InputStream openUrlStream(XsdDescriptor xsdDescriptor) {
return openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( xsdDescriptor.getLocalResourceName() ) );
}
private InputStream openUrlStream(URL url) {
try {
return url.openStream();
}
catch (IOException e) {
throw new XmlInfrastructureException( "Could not open url stream : " + url.toExternalForm(), e );
}
}
private InputStream resolveInLocalNamespace(String path) {
try {
return resourceStreamLocator.locateResourceStream( path );
}
catch ( Throwable t ) {
return null;
}
}
public static final DtdDescriptor MAPPING_DTD = new DtdDescriptor(
"www.hibernate.org/dtd/hibernate-mapping",
"org/hibernate/hibernate-mapping-3.0.dtd"
);
public static final DtdDescriptor ALTERNATE_MAPPING_DTD = new DtdDescriptor(View on GitHub (pinned to fad1729dce)
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
Example fix
<!-- before --> <hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping" xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping http://www.hibernate.org/dtd/hibernate-mapping-4.0.xsd"> <!-- after: let Hibernate resolve its bundled XSD --> <hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping">
Defensive patterns
Strategy: validation
Validate before calling
// CI check: parse all mapping documents fully offline; if any schema resolution goes remote, fail // and inspect xsi:schemaLocation attributes before shipping: // grep -r "schemaLocation" src/main/resources -l should only list Hibernate-standard namespaces
Try / catch
catch (XmlInfrastructureException e) {
throw new IllegalStateException("Could not open stream for a resolved schema URL - check custom schemaLocation hints and network access", e);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Encountered unsupported orm.xml xsd version [{}]
- Invalid URL
- Unable to open URL InputStream
- Unable to locate schema [${schemaResourceName}] via classpat
- Stream error handling schema url [${schemaUrl}]
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/76e7890cd35d1c32.
Report an issue: GitHub.