{"record":{"id":"820bafad936356b3","repo":"quarkusio/quarkus","slug":"failed-to-locate-the-origin-of-name","errorCode":null,"errorMessage":"Failed to locate the origin of ${name}","messagePattern":"Failed to locate the origin of (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/options/BootstrapMavenOptions.java","lineNumber":266,"sourceCode":"        } catch (ClassNotFoundException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new IllegalStateException(\"Failed to parse command line arguments \" + Arrays.asList(args), e);\n        }\n    }\n\n    /**\n     * Returns the JAR or the root directory that contains the class file that is on the\n     * classpath of the context classloader\n     */\n    public static Path getClassOrigin(Class<?> cls) throws IOException {\n        return getResourceOrigin(cls.getClassLoader(), ClassLoaderHelper.fromClassNameToResourceName(cls.getName()));\n    }\n\n    public static Path getResourceOrigin(ClassLoader cl, final String name) throws IOException {\n        URL url = cl.getResource(name);\n        if (url == null) {\n            throw new IOException(\"Failed to locate the origin of \" + name);\n        }\n        String classLocation = url.toExternalForm();\n        if (url.getProtocol().equals(\"jar\")) {\n            classLocation = classLocation.substring(4, classLocation.length() - name.length() - 2);\n        } else {\n            classLocation = classLocation.substring(0, classLocation.length() - name.length());\n        }\n        return urlSpecToPath(classLocation);\n    }\n\n    private static Path urlSpecToPath(String urlSpec) throws IOException {\n        try {\n            return Paths.get(new URL(urlSpec).toURI());\n        } catch (Throwable e) {\n            throw new IOException(\n                    \"Failed to create an instance of \" + Path.class.getName() + \" from \" + urlSpec, e);\n        }\n    }","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/options/BootstrapMavenOptions.java#L248-L284","documentation":"getResourceOrigin(ClassLoader, name) locates a resource (e.g. a class file of BootstrapMavenOptions) via cl.getResource(name) to determine which jar/directory it came from. If the resource is not found it throws IOException 'Failed to locate the origin of <name>'. This origin URL is required to add the bootstrap classes to the parser's URLClassLoader.","triggerScenarios":"Calling BootstrapMavenOptions.newInstance()/parse() -> getClassOrigin(cls) when the class's own resource cannot be found through its classloader - e.g. the class is generated in memory, loaded by a classloader without resource access, or comes from a nested/layered archive (Spring Boot fat jar, custom launcher) where fromClassNameToResourceName lookups fail.","commonSituations":"Running inside an executable fat jar where quarkus-bootstrap classes are nested, custom module-layer/classloader setups in tests or app servers, shaded/relocated jars, or bootstrap classes loaded from a non-file/non-jar URL scheme.","solutions":["Ensure quarkus-bootstrap-maven-resolver classes are loadable as resources from a plain jar or directory classpath entry","When embedding, unzip the nested jar to a directory and add it to the real classpath instead of loading via a custom in-memory classloader","Check the resource name derived from the class (io/quarkus/bootstrap/resolver/maven/options/BootstrapMavenOptions.class) is present in the deployed artifact","Avoid shading quarkus-bootstrap classes into another jar with relocation that breaks the resource path"],"exampleFix":"// before: running from nested jar\njava -jar app.jar  // BootstrapMavenOptions.class not resolvable as a resource\n// after: explode and put on classpath\nunzip app.jar -d app/ && java -cp \"app/BOOT-INF/lib/quarkus-bootstrap-maven-resolver-*.jar:...\" Main","handlingStrategy":"try-catch","validationCode":"String resource = BootstrapMavenOptions.class.getName().replace('.', '/') + \".class\";\nif (BootstrapMavenOptions.class.getClassLoader().getResource(resource) == null) {\n    throw new IllegalStateException(\"Class origin not locatable (nested/shaded jar?): \" + resource);\n}","typeGuard":null,"tryCatchPattern":"try {\n    BootstrapMavenOptions options = BootstrapMavenOptions.newInstance(cmdLine);\n} catch (IllegalStateException | IOException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Failed to locate the origin\")) {\n        throw new IllegalStateException(\"Bootstrap classes must be on a plain jar/directory classpath, not nested archive\", e);\n    }\n    throw e;\n}","preventionTips":["Avoid loading quarkus-bootstrap classes from nested fat-jar archives or in-memory classloaders","Do not shade/relocate quarkus-bootstrap packages","Test your deployment layout early: resolve BootstrapMavenOptions' origin before relying on the parser","Explode nested jars onto the real classpath when embedding"],"tags":["classpath","io","reflection","classloader"],"backgroundTag":"class-resource-not-found","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"}