quarkusio/quarkus · error · IllegalStateException
Failed to parse command line arguments ${Arrays.asList(args)
Error message
Failed to parse command line arguments ${Arrays.asList(args)} What it means
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 [...]'.
Source
Thrown at independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/options/BootstrapMavenOptions.java:251
this.activeProfileIds = activeProfiles;
this.inactiveProfileIds = inactiveProfiles;
} else {
activeProfileIds = Collections.emptyList();
inactiveProfileIds = Collections.emptyList();
}
}
@SuppressWarnings("unchecked")
private static Map<String, Object> invokeParser(ClassLoader cl, String[] args) throws ClassNotFoundException {
try {
final Class<?> parserCls = cl
.loadClass("io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptionsParser");
final Method parseMethod = parserCls.getMethod("parse", String[].class);
return (Map<String, Object>) parseMethod.invoke(null, (Object) args);
} catch (ClassNotFoundException e) {
throw e;
} catch (Exception e) {
throw new IllegalStateException("Failed to parse command line arguments " + Arrays.asList(args), e);
}
}
/**
* Returns the JAR or the root directory that contains the class file that is on the
* classpath of the context classloader
*/
public static Path getClassOrigin(Class<?> cls) throws IOException {
return getResourceOrigin(cls.getClassLoader(), ClassLoaderHelper.fromClassNameToResourceName(cls.getName()));
}
public static Path getResourceOrigin(ClassLoader cl, final String name) throws IOException {
URL url = cl.getResource(name);
if (url == null) {
throw new IOException("Failed to locate the origin of " + name);
}
String classLocation = url.toExternalForm();
if (url.getProtocol().equals("jar")) {View on GitHub (pinned to e1c734241f)
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
Example fix
// before: lib dir with mixed jars /opt/apache-maven/lib/maven-core-3.8.1.jar + maven-embedder-3.9.9.jar // after: clean single distribution rm -rf /opt/apache-maven && tar xzf apache-maven-3.9.9-bin.tar.gz -C /opt
Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure the parser class is loadable before invoking reflectively
Path mvnLib = Path.of(mavenHome, "lib");
try (Stream<Path> s = Files.list(mvnLib)) {
boolean hasEmbedder = s.anyMatch(p -> p.getFileName().toString().startsWith("maven-embedder-"));
if (!hasEmbedder) throw new IllegalStateException("Inconsistent Maven lib dir (no maven-embedder): " + mvnLib);
} Try / catch
try {
BootstrapMavenOptions options = BootstrapMavenOptions.newInstance(cmdLine);
} catch (IllegalStateException e) {
if (e.getMessage().startsWith("Failed to parse command line arguments")) {
log.error("Parser invocation failed; check Maven lib dir consistency and the args " + e.getCause());
}
throw e;
} Prevention
- 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)
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Expected : after attribute
- Unable to find a template for these candidates ${candidates}
- Failed to resolve maven plugin version containing <cls>
- Failed to locate io.quarkus:quarkus-core-deployment on the a
- Failed to locate <pomPropsPath> on the classpath
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/ec1c7d9c79af9872.
Report an issue: GitHub.