{"record":{"id":"07661ff30e8ee67f","repo":"quarkusio/quarkus","slug":"unable-to-find-main-method-on-class-originalmai","errorCode":null,"errorMessage":"Unable to find main method on class '${originalMainClassName}' while it was also not possible to traverse the class hierarchy","messagePattern":"Unable to find main method on class '(.+?)' while it was also not possible to traverse the class hierarchy","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java","lineNumber":716,"sourceCode":"            }\n            if (!result.isValid) {\n                // this means there were private main methods that we ignored\n                result = resultFromSuper(originalMainClassName, classVisitor, transformer, currentClassInfo);\n            }\n\n            return result;\n        }\n\n        private Result resultFromSuper(String originalMainClassName, ClassVisitor outputClassVisitor,\n                ClassTransformer transformer, ClassInfo currentClassInfo) {\n            DotName superName = currentClassInfo.superName();\n            if (superName.equals(OBJECT)) {\n                // no valid main method was found\n                return Result.invalid();\n            }\n            ClassInfo superClassInfo = index.getClassByName(superName);\n            if (superClassInfo == null) {\n                throw new IllegalStateException(\"Unable to find main method on class '\" + originalMainClassName\n                        + \"' while it was also not possible to traverse the class hierarchy\");\n            }\n\n            // check if the superclass has any valid candidates\n            return doApply(originalMainClassName, outputClassVisitor, transformer, superClassInfo);\n        }\n\n        private static String errorMessage(String originalMainClassName) {\n            return \"Unable to find a valid main method on class '\" + originalMainClassName\n                    + \"'. See https://openjdk.org/jeps/445 for details of what constitutes a valid main method.\";\n        }\n\n        private static MethodCreator createStandardMain(ClassTransformer transformer) {\n            return transformer.addMethod(\"main\", void.class, String[].class)\n                    .setModifiers(Modifier.PUBLIC | Modifier.STATIC);\n        }\n\n        private static class Result {","sourceCodeStart":698,"sourceCodeEnd":734,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java#L698-L734","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before\npublic class MyApp extends SomeUnindexedBase { } // main only in base\n// after\npublic class MyApp extends SomeUnindexedBase {\n    public static void main(String[] args) { SomeUnindexedBase.run(args); }\n}","handlingStrategy":"validation","validationCode":"Class<?> c = Main.class;\nwhile (c != null && !c.equals(Object.class)) {\n    for (Method m : c.getDeclaredMethods()) {\n        if (m.getName().equals(\"main\")\n                && java.lang.reflect.Modifier.isStatic(m.getModifiers())\n                && Arrays.equals(m.getParameterTypes(), new Class<?>[]{String[].class})) {\n            return; // found in hierarchy\n        }\n    }\n    c = c.getSuperclass();\n}\nthrow new IllegalStateException(\"No main in hierarchy; declare one in your main class\");","typeGuard":null,"tryCatchPattern":"try {\n    quarkusBuild();\n} catch (IllegalStateException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"not possible to traverse the class hierarchy\")) {\n        // index the superclass jar or declare main directly\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["quarkus","jandex","classloading","main-method"],"backgroundTag":"unindexed-class-hierarchy","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"}