hibernate/hibernate-orm · error · ConfigurationException
Could not locate cfg.xml resource [%s]
Error message
Could not locate cfg.xml resource [%s]
What it means
Error "Could not locate cfg.xml resource [%s]" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/cfgxml/internal/ConfigLoader.java:56
public JaxbCfgProcessor initialize() {
return new JaxbCfgProcessor( bootstrapServiceRegistry.getService( ClassLoaderService.class ) );
}
}
);
public ConfigLoader(BootstrapServiceRegistry bootstrapServiceRegistry) {
this.bootstrapServiceRegistry = bootstrapServiceRegistry;
}
private InputStream locateStream(String cfgXmlResourceName) {
return bootstrapServiceRegistry.requireService( ClassLoaderService.class )
.locateResourceStream( cfgXmlResourceName );
}
public LoadedConfig loadConfigXmlResource(String cfgXmlResourceName) {
final var stream = locateStream( cfgXmlResourceName );
if ( stream == null ) {
throw new ConfigurationException( "Could not locate cfg.xml resource [" + cfgXmlResourceName + "]" );
}
try {
return LoadedConfig.consume( jaxbProcessorHolder.getValue()
.unmarshal( stream, new Origin( RESOURCE, cfgXmlResourceName ) ) );
}
finally {
try {
stream.close();
}
catch (IOException e) {
BOOT_LOGGER.unableToCloseCfgXmlResourceStream( e );
}
}
}
public LoadedConfig loadConfigXmlFile(File cfgXmlFile) {
try ( FileInputStream cfgFileStream = new FileInputStream( cfgXmlFile ) ) {View on GitHub (pinned to fad1729dce)
Solutions
- Place hibernate.cfg.xml (or the named cfg.xml resource) on the classpath root, e.g. src/main/resources.
- Check the resource path passed to configure()/Configuration for typos, including case sensitivity.
- Ensure the build tool copies resource files into the output artifact (target/classes or the jar).
When it happens
Trigger: A hibernate.cfg.xml resource named in the configuration cannot be found.
Common situations: Referencing cfg.xml by a wrong classpath path or file path, or the file not being packaged into the deployment.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/b30c443a343258a5.
Report an issue: GitHub.