{"record":{"id":"ec1c7d9c79af9872","repo":"quarkusio/quarkus","slug":"failed-to-parse-command-line-arguments-arrays-as","errorCode":null,"errorMessage":"Failed to parse command line arguments ${Arrays.asList(args)}","messagePattern":"Failed to parse command line arguments (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/options/BootstrapMavenOptions.java","lineNumber":251,"sourceCode":"            this.activeProfileIds = activeProfiles;\n            this.inactiveProfileIds = inactiveProfiles;\n        } else {\n            activeProfileIds = Collections.emptyList();\n            inactiveProfileIds = Collections.emptyList();\n        }\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private static Map<String, Object> invokeParser(ClassLoader cl, String[] args) throws ClassNotFoundException {\n        try {\n            final Class<?> parserCls = cl\n                    .loadClass(\"io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptionsParser\");\n            final Method parseMethod = parserCls.getMethod(\"parse\", String[].class);\n            return (Map<String, Object>) parseMethod.invoke(null, (Object) args);\n        } 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\")) {","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/options/BootstrapMavenOptions.java#L233-L269","documentation":"invokeParser() reflectively loads io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptionsParser from a URLClassLoader over the Maven lib directory and calls its static parse(String[]) method. Any reflective invocation failure other than ClassNotFoundException (missing parser class, method mismatch, exception thrown inside the parser, IllegalAccess) is wrapped in IllegalStateException 'Failed to parse command line arguments [...]'.","triggerScenarios":"Calling BootstrapMavenOptions.newInstance()/parse() where the parser class loads but parse(String[]) fails: the Maven version in <mavenHome>/lib ships an incompatible parser implementation, the parser itself throws (e.g. bad CLIManager), or reflective access is blocked.","commonSituations":"Mixed Maven versions where the lib dir contains jars from different distributions, a Maven upgrade that changed the target class, security manager / JPMS restrictions on reflective access, or JVM arguments blocking class definition.","solutions":["Inspect the wrapped cause: if it comes from inside the parser, fix the offending command line argument listed in the message","Verify <mavenHome>/lib contains a consistent single Maven distribution (no mixed-version jars); reinstall if unsure","Check the BootstrapMavenOptionsParser class exists and matches the expected static parse(String[]) signature for your Maven version","Upgrade quarkus-bootstrap/maven-resolver to a version compatible with the installed Maven distribution"],"exampleFix":"// before: lib dir with mixed jars\n/opt/apache-maven/lib/maven-core-3.8.1.jar + maven-embedder-3.9.9.jar\n// after: clean single distribution\nrm -rf /opt/apache-maven && tar xzf apache-maven-3.9.9-bin.tar.gz -C /opt","handlingStrategy":"try-catch","validationCode":"// Ensure the parser class is loadable before invoking reflectively\nPath mvnLib = Path.of(mavenHome, \"lib\");\ntry (Stream<Path> s = Files.list(mvnLib)) {\n    boolean hasEmbedder = s.anyMatch(p -> p.getFileName().toString().startsWith(\"maven-embedder-\"));\n    if (!hasEmbedder) throw new IllegalStateException(\"Inconsistent Maven lib dir (no maven-embedder): \" + mvnLib);\n}","typeGuard":null,"tryCatchPattern":"try {\n    BootstrapMavenOptions options = BootstrapMavenOptions.newInstance(cmdLine);\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"Failed to parse command line arguments\")) {\n        log.error(\"Parser invocation failed; check Maven lib dir consistency and the args \" + e.getCause());\n    }\n    throw e;\n}","preventionTips":["Never mix jars from different Maven versions in one lib directory","Use a single pinned Maven distribution matching the resolver's expectations","Avoid security managers / JPMS flags that block reflective access","Keep quarkus-bootstrap and Maven versions aligned (upgrade together)"],"tags":["reflection","maven","command-line","classpath"],"backgroundTag":"reflective-invocation-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}