{"record":{"id":"7771d1f6cd0ada08","repo":"hibernate/hibernate-orm","slug":"unable-to-open-specified-script-source-url","errorCode":null,"errorMessage":"Unable to open specified script source url [","messagePattern":"Unable to open specified script source url \\[","errorType":"exception","errorClass":"SchemaManagementException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromUrl.java","lineNumber":53,"sourceCode":"\t\tthis.url = url;\n\t\tthis.charsetName = charsetName;\n\t}\n\n\t@Override\n\tpublic String getScriptDescription() {\n\t\treturn url.toExternalForm();\n\t}\n\n\t@Override\n\tprotected Reader prepareReader() {\n\t\ttry {\n\t\t\tfinal var stream = url.openStream();\n\t\t\treturn charsetName != null\n\t\t\t\t\t? new InputStreamReader( stream, charsetName )\n\t\t\t\t\t: new InputStreamReader( stream );\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new SchemaManagementException(\n\t\t\t\t\t\"Unable to open specified script source url [\" + url + \"] for reading (\" + charsetName + \")\"\n\t\t\t);\n\t\t}\n\t}\n\n\t@Override\n\tprotected void releaseReader(Reader reader) {\n\t\ttry {\n\t\t\treader.close();\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tLOG.warn( \"Unable to close file reader for generation script source\" );\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean containsScript(URL url) {\n\t\treturn this.url.equals( url );","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromUrl.java#L35-L71","documentation":"Raised when a script SOURCE given as a URL cannot be opened: url.openStream() threw IOException. Two practical traps: the original IOException is NOT chained (message-only exception), so the real reason is hidden; and the charset name is embedded in the message because an unsupported charset makes the InputStreamReader constructor throw UnsupportedEncodingException — an IOException caught here. Diagnose by opening the URL yourself.","triggerScenarios":"jakarta.persistence.sql-load-script-source / hibernate.hbm2ddl.import_files value is a URL (file:, http:, jar:) whose resource is missing (404, deleted from jar, renamed resource), or the configured charset name is unsupported. Stream-open failures on remounted/invalidated jars also land here.","commonSituations":"Spring Boot fat-jar repackaging changing nested resource URLs, script moved between modules, typo in resource name, malformed URL, exotic charset name passed for import script decoding.","solutions":["Probe the URL yourself (url.openStream() in try-with-resources) to see the real IOException Hibernate swallowed.","Fix the resource location; re-verify the URL after repackaging — fat jars change nested-jar URLs.","If it is a plain file, use a plain path or a verified file: URL rather than a stale one.","Use a standard charset name (UTF-8) for the script charset setting."],"exampleFix":"// diagnosis snippet — reveals the hidden IOException\ntry ( var in = url.openStream() ) { /* resource is fine */ }\ncatch ( IOException e ) { e.printStackTrace(); /* real cause: 404, missing jar entry, charset */ }","handlingStrategy":"validation","validationCode":"try ( var ignored = url.openStream() ) {\n    // resource openable\n}\ncatch ( IOException e ) {\n    throw new IllegalStateException( \"Import script URL not openable: \" + url, e ); // shows the real IOException\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate script-source URLs with an openStream() probe during startup smoke tests.","Avoid fragile nested-jar URLs for long-lived config; prefer filesystem paths for import scripts.","Percent-encode URLs correctly and test resource resolution after every repackaging.","Use standard charset names; include the charset in your diagnosis when it appears in the message."],"tags":["hibernate","schema-management","import-script","url","resource-not-found"],"backgroundTag":"sql-script-url-not-found","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}