{"record":{"id":"845513ea10d9d643","repo":"hibernate/hibernate-orm","slug":"unable-to-access","errorCode":null,"errorMessage":"Unable to access [{}]","messagePattern":"Unable to access \\[(.+?)\\]","errorType":"exception","errorClass":"PersistenceException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/jpa/boot/spi/PersistenceXmlParser.java","lineNumber":330,"sourceCode":"\n\tprivate JaxbPersistenceImpl loadUrlWithJaxb(URL xmlUrl) {\n\t\tfinal String resourceName = xmlUrl.toExternalForm();\n\t\ttry {\n\t\t\tvar connection = xmlUrl.openConnection();\n\t\t\t// avoid JAR locking on Windows and Tomcat\n\t\t\tconnection.setUseCaches( false );\n\t\t\ttry ( var inputStream = connection.getInputStream() ) {\n\t\t\t\treturn new ConfigurationBinder( classLoaderService )\n\t\t\t\t\t\t.bind( new StreamSource( inputStream ),\n\t\t\t\t\t\t\t\tnew Origin( SourceType.URL, resourceName ) )\n\t\t\t\t\t\t.getRoot();\n\t\t\t}\n\t\t\tcatch (IOException e) {\n\t\t\t\tthrow new PersistenceException( \"Unable to obtain input stream from [\" + resourceName + \"]\", e );\n\t\t\t}\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new PersistenceException( \"Unable to access [\" + resourceName + \"]\", e );\n\t\t}\n\t}\n\n}\n","sourceCodeStart":312,"sourceCodeEnd":335,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/jpa/boot/spi/PersistenceXmlParser.java#L312-L335","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before: java -cp 'app.jar:lib/*' ...  with lib jar referenced via nested jar: URL\n# after: run as an executable jar so Spring Boot's LaunchedURLClassLoader resolves nested entries\njava -jar app.jar","handlingStrategy":"try-catch","validationCode":"// reproduce the connect outside Hibernate to verify URL support\nfor (URL u : Collections.list(cl.getResources(\"META-INF/persistence.xml\"))) {\n    try { u.openConnection(); } catch (IOException io) { throw new IllegalStateException(\"Unsupported/unreachable URL: \" + u, io); }\n}","typeGuard":null,"tryCatchPattern":"catch (PersistenceException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Unable to access\")) {\n        log.error(\"Cannot connect to persistence.xml URL: {} - check nested-jar/VFS URL support\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["hibernate","jpa","persistence-xml","url-connection","io","deployment"],"backgroundTag":"resource-access-failed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}