hibernate/hibernate-orm · error · XsdException

Unable to locate schema [%s] via classpath

Error message

Unable to locate schema [%s] via classpath

What it means

Error "Unable to locate schema [%s] via classpath" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/cfgxml/internal/JaxbCfgProcessor.java:157

	}

	private Schema schema;

	private Schema schema() {
		if ( schema == null ) {
			schema = resolveLocalSchema( "org/hibernate/hibernate-configuration-4.0.xsd" );
		}
		return schema;
	}

	private Schema resolveLocalSchema(String schemaName) {
		return resolveLocalSchema( schemaName, W3C_XML_SCHEMA_NS_URI );
	}

	private Schema resolveLocalSchema(String schemaName, String schemaLanguage) {
		final URL url = classLoaderService.locateResource( schemaName );
		if ( url == null ) {
			throw new XsdException( "Unable to locate schema [" + schemaName + "] via classpath", schemaName );
		}
		try {
			final var schemaStream = url.openStream();
			try {
				return SchemaFactory.newInstance( schemaLanguage )
						.newSchema( new StreamSource( url.openStream() ) );
			}
			catch ( SAXException | IOException e ) {
				throw new XsdException( "Unable to load schema [" + schemaName + "]", e, schemaName );
			}
			finally {
				try {
					schemaStream.close();
				}
				catch ( IOException e ) {
					JAXB_LOGGER.problemClosingSchemaStream( e.toString() );
				}
			}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Ensure the schema resource (XSD) is packaged on the classpath at the expected location (org/hibernate/...).
  2. If running with a custom classloader or modular environment, make sure the hibernate-core resources are visible.
  3. Do not strip resource files when shading/minimizing the jar.

When it happens

Trigger: The XSD schema used to validate the configuration cannot be located or loaded.

Common situations: Custom schema resolution failing because the schema resource is missing from the classpath or the schema URL is unreachable.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/049349932fe6f195. Report an issue: GitHub.