{"record":{"id":"48799bc54c9ff069","repo":"quarkusio/quarkus","slug":"unable-to-create-protection-domain-for-jarpath","errorCode":null,"errorMessage":"Unable to create protection domain for ${jarPath}","messagePattern":"Unable to create protection domain for (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/JarResource.java","lineNumber":58,"sourceCode":"        this.jarPath = jarPath;\n    }\n\n    @Override\n    public void init() {\n        final URL url;\n        try {\n            String path = jarPath.toAbsolutePath().toString();\n            if (!path.startsWith(\"/\")) {\n                path = '/' + path;\n            }\n            // we use this particular constructor to work around https://bugs.openjdk.org/browse/JDK-8140634\n            // see https://github.com/quarkusio/quarkus/issues/52292\n            URI uri = new URI(\"file\", null, path, null, null);\n            JarUrlStreamHandler handler = new JarUrlStreamHandler(uri);\n            url = new URL((URL) null, uri.toString(), handler);\n            handler.setOriginalUrl(url);\n        } catch (URISyntaxException | MalformedURLException e) {\n            throw new RuntimeException(\"Unable to create protection domain for \" + jarPath, e);\n        }\n        this.protectionDomain = new ProtectionDomain(new CodeSource(url, (Certificate[]) null), null);\n    }\n\n    @Override\n    public byte[] getResourceData(String resource) {\n        return JarFileReference.withJarFile(this, resource, JarResourceDataProvider.INSTANCE);\n    }\n\n    private static class JarResourceDataProvider implements JarFileReference.JarFileConsumer<byte[]> {\n        private static final JarResourceDataProvider INSTANCE = new JarResourceDataProvider();\n\n        @Override\n        public byte[] apply(JarFile jarFile, Path path, String res) {\n            ZipEntry entry = jarFile.getEntry(res);\n            if (entry == null) {\n                return null;\n            }","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/JarResource.java#L40-L76","documentation":"Wraps URISyntaxException or MalformedURLException raised while constructing the file URI and JarUrlStreamHandler used for the jar resource's protection domain CodeSource URL. Thrown from JarResource init when the jar path cannot be converted into a valid file URL.","triggerScenarios":"JarResource init builds new URI(\"file\", null, path, null, null) and a URL from it; failure means the jarPath string is malformed (illegal characters, empty, or not a valid path) so URI/URL creation fails.","commonSituations":"Unusual characters in the install path (spaces/unicode on misconfigured systems), jarPath built from an uninitialized or null-wrapped value, or exotic environments where Path string conversion produces an invalid URI component.","solutions":["Inspect the printed jarPath for invalid characters or emptiness; install the app under a simple ASCII path without spaces.","Rebuild the application so the runner receives a canonical absolute path (Path.toAbsolutePath().normalize()).","Check how the classpath/jar path is passed to QuarkusEntryPoint (env vars, wrapper scripts) for corruption.","Upgrade Quarkus if you suspect a URI-encoding bug in your environment (see linked issue quarkusio/quarkus#52292 context)."],"exampleFix":"// before\njava -jar /path with spaces/app.jar\n// after\njava -jar \"/path_with_no_spaces/app.jar\"  # or symlink a clean path","handlingStrategy":"validation","validationCode":"String path = jarPath;\nif (path == null || path.isBlank() || !java.nio.file.Paths.get(path).isAbsolute()) throw new IllegalStateException(\"invalid jar path: \" + path);\nURI u = new URI(\"file\", null, path, null, null); // fail fast with clear message","typeGuard":"boolean isUriSafePath(String p) { return p != null && !p.isBlank() && java.nio.file.Paths.get(p).isAbsolute(); }","tryCatchPattern":"try { app.start(); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to create protection domain\")) { log.error(\"Bad jar path/URI: {}\", e.getMessage(), e.getCause()); throw new IllegalStateException(\"Install app under a clean absolute path\", e); } throw e; }","preventionTips":["Install under ASCII paths without spaces or special characters.","Always pass canonical absolute paths to the launcher.","Validate launcher scripts/env vars that carry the jar path.","Test the same install layout in CI before production deploy."],"tags":["url","uri","classloading","startup"],"backgroundTag":"malformed-url","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}