{"record":{"id":"03336ba5a8459cc3","repo":"quarkusio/quarkus","slug":"unable-to-find-a-valid-main-method-on-class-ori","errorCode":null,"errorMessage":"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.","messagePattern":"Unable to find a valid main method on class '(.+?)'\\. See https://openjdk\\.org/jeps/445 for details of what constitutes a valid main method\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java","lineNumber":590,"sourceCode":"     */\n    private static class MainMethodTransformer implements BiFunction<String, ClassVisitor, ClassVisitor> {\n\n        private final IndexView index;\n\n        public MainMethodTransformer(IndexView index) {\n            this.index = index;\n        }\n\n        @Override\n        public ClassVisitor apply(String mainClassName, ClassVisitor outputClassVisitor) {\n            ClassInfo mainClassInfo = index.getClassByName(mainClassName);\n            if (mainClassInfo == null) {\n                throw new IllegalStateException(mainClassName + \" should have a corresponding ClassInfo at this point\");\n            }\n            ClassTransformer transformer = new ClassTransformer(mainClassName);\n            Result result = doApply(mainClassName, outputClassVisitor, transformer, mainClassInfo);\n            if (!result.isValid) {\n                throw new RuntimeException(errorMessage(mainClassName));\n            }\n            if (result.classVisitor == null) {\n                throw new IllegalStateException(\"result.classvisitor should not be null at this point\");\n            }\n            return result.classVisitor;\n        }\n\n        private Result doApply(String originalMainClassName,\n                ClassVisitor classVisitor, ClassTransformer transformer,\n                ClassInfo currentClassInfo) {\n            boolean isTopLevel = currentClassInfo.name().toString().equals(originalMainClassName);\n            boolean allowStatic = isTopLevel;\n            boolean hasStaticWithArgs = false;\n            boolean hasStaticWithoutArgs = false;\n            boolean hasInstanceWithArgs = false;\n            boolean hasInstanceWithoutArgs = false;\n\n            MethodInfo withArgs = currentClassInfo.method(\"main\", STRING_ARRAY);","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java#L572-L608","documentation":"After locating the configured main class, Quarkus transforms its bytecode to generate a standard static main entry point. doApply validates that the class contains a valid main-method candidate per JEP 445 rules (public static void main(String[]), or supported instance forms); if none is valid, this RuntimeException is thrown pointing at the JEP 445 definition.","triggerScenarios":"In the ClassVisitor's apply(): Result.isValid is false after scanning the main class and its hierarchy — no method matching a valid main signature exists on the class configured as quarkus.main-class or auto-detected main class.","commonSituations":"Main method declared with the wrong signature (non-static, non-public, missing String[] parameter, wrong casing 'Main'); main method with an incompatible parameter type; class only has a 'void main()' instance method under a Java version whose support doesn't match; abstract class without an inherited concrete main.","solutions":["Declare the main method as public static void main(String[] args) in the configured class","Fix the signature casing/modifiers of the existing main method","Add the missing String[] parameter or remove unsupported extra parameters","Check the quarkus.main-class value points at the class that actually contains the main method"],"exampleFix":"// before\npublic class Main {\n    void main() { System.out.println(\"hi\"); }\n}\n// after\npublic class Main {\n    public static void main(String[] args) { System.out.println(\"hi\"); }\n}","handlingStrategy":"validation","validationCode":"Class<?> c = Main.class;\nfor (Method m : c.getDeclaredMethods()) {\n    if (m.getName().equals(\"main\")\n            && java.lang.reflect.Modifier.isPublic(m.getModifiers())\n            && java.lang.reflect.Modifier.isStatic(m.getModifiers())\n            && Arrays.equals(m.getParameterTypes(), new Class<?>[]{String[].class})) {\n        return; // valid\n    }\n}\nthrow new IllegalStateException(\"No valid public static void main(String[]) on \" + c.getName());","typeGuard":null,"tryCatchPattern":"try {\n    quarkusBuild();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Unable to find a valid main method\")) {\n        // fix the main method signature per JEP 445\n    }\n    throw e;\n}","preventionTips":["Standard signature: public static void main(String[] args)","Check modifiers/parameter types when the compiler or IDE warns about entry points","Point quarkus.main-class at the class that actually declares main","Prefer @QuarkusMain classes implementing QuarkusApplication to avoid signature pitfalls"],"tags":["quarkus","main-method","jep445","build-time"],"backgroundTag":"missing-main-method","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"}