quarkusio/quarkus · error · MojoFailureException
Cannot specify both class and method name
Error message
Cannot specify both class and method name
What it means
AnalyseCallTreeMojo.execute rejects a configuration where both `className` and `methodName` parameters are set, because the analysis target must be either a whole class or a single fully-qualified method, not both. Thrown as MojoFailureException before any report parsing.
Source
Thrown at devtools/maven/src/main/java/io/quarkus/maven/AnalyseCallTreeMojo.java:33
* -H:+PrintAnalysisCallTree,
* and does a more meaningful analysis of what is causing a type to be retained.
*/
@Mojo(name = "analyze-call-tree")
public class AnalyseCallTreeMojo extends AbstractMojo {
@Parameter(defaultValue = "${class}")
private String className;
@Parameter(defaultValue = "${method}")
private String methodName;
@Parameter(defaultValue = "${project.build.directory}/reports")
private File reportsDir;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (methodName != null && className != null) {
throw new MojoFailureException("Cannot specify both class and method name");
}
String clazz = className;
String method = "<init>";
if (methodName != null) {
int index = methodName.lastIndexOf('.');
clazz = methodName.substring(0, index);
method = methodName.substring(index + 1);
}
File[] files = reportsDir.listFiles();
if (files == null) {
throw new MojoFailureException("No reports in " + reportsDir);
}
for (File i : files) {
if (i.getName().startsWith("call_tree")) {
try {
System.out.println(new ReportAnalyzer(i.getAbsolutePath()).analyse(clazz, method));
} catch (Exception e) {View on GitHub (pinned to e1c734241f)
Solutions
- Remove one of the two parameters: use -DmethodName=com.acme.MyClass.myMethod for a method, or -DclassName=com.acme.MyClass for the class.
- Check pom.xml <configuration> for a lingering className/methodName setting.
Example fix
// before mvn quarkus:analyze-call-tree -DclassName=com.acme.Foo -DmethodName=com.acme.Foo.run // after mvn quarkus:analyze-call-tree -DmethodName=com.acme.Foo.run
Defensive patterns
Strategy: validation
Validate before calling
if ([project.hasProperty('className'), project.hasProperty('methodName')].count { it } > 1) throw new IllegalArgumentException('Set only one of className or methodName') Try / catch
try { ... } catch (MojoFailureException e) { log.error('Call-tree target misconfigured: ' + e.getMessage()); } Prevention
- Choose one analysis target style and stick to it in CI.
- Prefer the combined -DmethodName=fqcn.method form for single methods.
When it happens
Trigger: Running `mvn quarkus:analyze-call-tree` with both -DclassName and -DmethodName properties defined.
Common situations: CI property inheritance where one parameter is set in pom.xml and the other on the command line; copy-paste of example commands including both flags.
Related errors
- Unsupported format: ${format}
- Either the `extension` or `extensions` parameter must be set
- Failed
- The project artifact's extension is '${extension}' while thi
- Specifying a stream requires the Quarkus extension registry
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/4b10cd60cfd7ef37.
Report an issue: GitHub.