hibernate/hibernate-orm · error · PersistenceException
Unable to access [{}]
Error message
Unable to access [{}] What it means
Thrown by PersistenceXmlParser.loadUrlWithJaxb() as a PersistenceException when xmlUrl.openConnection() itself raises an IOException before any stream is obtained - i.e. the URL to a persistence.xml cannot be connected to at all. It is the outer catch, distinguishing 'cannot connect to the resource' (this error) from 'connected but could not read' (the input-stream error).
Source
Thrown at hibernate-core/src/main/java/org/hibernate/jpa/boot/spi/PersistenceXmlParser.java:330
private JaxbPersistenceImpl loadUrlWithJaxb(URL xmlUrl) {
final String resourceName = xmlUrl.toExternalForm();
try {
var connection = xmlUrl.openConnection();
// avoid JAR locking on Windows and Tomcat
connection.setUseCaches( false );
try ( var inputStream = connection.getInputStream() ) {
return new ConfigurationBinder( classLoaderService )
.bind( new StreamSource( inputStream ),
new Origin( SourceType.URL, resourceName ) )
.getRoot();
}
catch (IOException e) {
throw new PersistenceException( "Unable to obtain input stream from [" + resourceName + "]", e );
}
}
catch (IOException e) {
throw new PersistenceException( "Unable to access [" + resourceName + "]", e );
}
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Check the resource name in the message and open it manually (new URL(...).openConnection()) to reproduce the failure outside Hibernate.
- Use a classloader/protocol setup that supports the URL scheme (e.g. Spring Boot's LaunchedURLClassLoader, proper VFS integration) so Hibernate receives only handler-supported URLs.
- Run from an exploded/classic jar layout if nested-jar URL handling keeps failing.
- Ensure the artifact and all classpath entries are stable (not deleted/moved) for the whole duration of bootstrap.
Example fix
# before: java -cp 'app.jar:lib/*' ... with lib jar referenced via nested jar: URL # after: run as an executable jar so Spring Boot's LaunchedURLClassLoader resolves nested entries java -jar app.jar
Defensive patterns
Strategy: try-catch
Validate before calling
// reproduce the connect outside Hibernate to verify URL support
for (URL u : Collections.list(cl.getResources("META-INF/persistence.xml"))) {
try { u.openConnection(); } catch (IOException io) { throw new IllegalStateException("Unsupported/unreachable URL: " + u, io); }
} Try / catch
catch (PersistenceException e) {
if (e.getMessage() != null && e.getMessage().contains("Unable to access")) {
log.error("Cannot connect to persistence.xml URL: {} - check nested-jar/VFS URL support", e.getMessage());
}
throw e;
} Prevention
- Use the launcher's intended classloader (e.g. Spring Boot's LaunchedURLClassLoader) so nested-jar URLs resolve.
- Prefer exploded or classic single-jar layouts when custom URL schemes are involved.
When it happens
Trigger: A persistence.xml URL whose protocol handler fails on connect: nested-jar URLs (jar:...jar!/META-INF/persistence.xml) unsupported by the JDK handler, virtual-filesystem URLs from app servers, file URLs to paths that no longer exist, or http URLs whose host refuses the connection.
Common situations: Spring Boot executable (nested) jars with a ClassLoader that leaks the inner jar URL to Hibernate; running on containers/modules systems (JBoss VFS) whose custom URL schemes confuse plain URLConnection; the archive being deleted or moved after classpath scanning catalogued it.
Related errors
- Unable to obtain input stream from [{}]
- Could not resolve jar-file: <jarFileReference>
- Unable to extract bytes from InputStream
- Unable to access stream from jar file [%s] for entry [%s]
- Error accessing jar file [<rootFilePath>]
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/845513ea10d9d643.
Report an issue: GitHub.