quarkusio/quarkus · error · IllegalStateException
Unable to find main method on class '${originalMainClassName
Error message
Unable to find main method on class '${originalMainClassName}' while it was also not possible to traverse the class hierarchy What it means
When no valid main method is found on the class itself, doApply walks up the superclass chain looking for one. If the superclass DotName cannot be resolved in the Jandex index (superClassInfo == null), resultFromSuper throws this IllegalStateException because traversal is impossible.
Source
Thrown at core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java:716
}
if (!result.isValid) {
// this means there were private main methods that we ignored
result = resultFromSuper(originalMainClassName, classVisitor, transformer, currentClassInfo);
}
return result;
}
private Result resultFromSuper(String originalMainClassName, ClassVisitor outputClassVisitor,
ClassTransformer transformer, ClassInfo currentClassInfo) {
DotName superName = currentClassInfo.superName();
if (superName.equals(OBJECT)) {
// no valid main method was found
return Result.invalid();
}
ClassInfo superClassInfo = index.getClassByName(superName);
if (superClassInfo == null) {
throw new IllegalStateException("Unable to find main method on class '" + originalMainClassName
+ "' while it was also not possible to traverse the class hierarchy");
}
// check if the superclass has any valid candidates
return doApply(originalMainClassName, outputClassVisitor, transformer, superClassInfo);
}
private static String errorMessage(String originalMainClassName) {
return "Unable to find a valid main method on class '" + originalMainClassName
+ "'. See https://openjdk.org/jeps/445 for details of what constitutes a valid main method.";
}
private static MethodCreator createStandardMain(ClassTransformer transformer) {
return transformer.addMethod("main", void.class, String[].class)
.setModifiers(Modifier.PUBLIC | Modifier.STATIC);
}
private static class Result {View on GitHub (pinned to e1c734241f)
Solutions
- Define a concrete public static void main(String[] args) directly in your main class so hierarchy traversal isn't needed
- Ensure the jar containing the superclass is Jandex-indexed (add a jandex.idx or META-INF/jandex.idx, or depend on the library's quarkus-published variant)
- Check dependency versions — the superclass artifact may be missing/corrupt in the local repository
- Simplify the main class hierarchy (don't rely on inheriting main from an unindexed parent)
Example fix
// before
public class MyApp extends SomeUnindexedBase { } // main only in base
// after
public class MyApp extends SomeUnindexedBase {
public static void main(String[] args) { SomeUnindexedBase.run(args); }
} Defensive patterns
Strategy: validation
Validate before calling
Class<?> c = Main.class;
while (c != null && !c.equals(Object.class)) {
for (Method m : c.getDeclaredMethods()) {
if (m.getName().equals("main")
&& java.lang.reflect.Modifier.isStatic(m.getModifiers())
&& Arrays.equals(m.getParameterTypes(), new Class<?>[]{String[].class})) {
return; // found in hierarchy
}
}
c = c.getSuperclass();
}
throw new IllegalStateException("No main in hierarchy; declare one in your main class"); Try / catch
try {
quarkusBuild();
} catch (IllegalStateException e) {
if (e.getMessage() != null && e.getMessage().contains("not possible to traverse the class hierarchy")) {
// index the superclass jar or declare main directly
}
throw e;
} Prevention
- Declare main directly in the main class rather than relying on inherited mains
- Ensure superclass jars are Jandex-indexed (META-INF/jandex.idx)
- Avoid generated superclasses unknown to the application index
- Keep parent-class dependency versions resolvable
When it happens
Trigger: In resultFromSuper (called from doApply): the candidate class has a non-Object superclass whose ClassInfo is absent from the application index — typically a superclass from an unindexed dependency.
Common situations: Main class extends a class from a third-party jar that isn't Jandex-indexed; a generated or dynamically added superclass unknown to the index; binary-incompatible dependency versions where the parent class can't be resolved.
Related errors
- Failed to load steps from %s
- The class (${name}) cannot be created during deployment.
- The class (${name}) cannot be created during deployment.
- Unable to find a valid main method on class '${originalMainC
- Unknown class: ${token}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/07661ff30e8ee67f.
Report an issue: GitHub.