{"record":{"id":"19181f3f37cee7e3","repo":"quarkusio/quarkus","slug":"unable-to-instantiate-parserhook-engineconfigcla","errorCode":null,"errorMessage":"Unable to instantiate ParserHook: <engineConfigClass>","messagePattern":"Unable to instantiate ParserHook: <engineConfigClass>","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java","lineNumber":702,"sourceCode":"            for (ClassInfo engineConfigClass : engineConfigurations.get().getConfigurations()) {\n                if (Types.isImplementorOf(engineConfigClass, Names.SECTION_HELPER_FACTORY, index)) {\n                    try {\n                        Class<?> sectionHelperFactoryClass = tccl.loadClass(engineConfigClass.toString());\n                        SectionHelperFactory<?> factory = (SectionHelperFactory<?>) sectionHelperFactoryClass\n                                .getDeclaredConstructor().newInstance();\n                        builder.addSectionHelper(factory);\n                        LOGGER.debugf(\"SectionHelperFactory registered during template analysis: %s\", engineConfigClass);\n                    } catch (Exception e) {\n                        throw new IllegalStateException(\"Unable to instantiate SectionHelperFactory: \" + engineConfigClass, e);\n                    }\n                } else if (Types.isImplementorOf(engineConfigClass, Names.PARSER_HOOK, index)) {\n                    try {\n                        Class<?> parserHookClass = tccl.loadClass(engineConfigClass.toString());\n                        ParserHook parserHook = (ParserHook) parserHookClass.getDeclaredConstructor().newInstance();\n                        builder.addParserHook(parserHook);\n                        LOGGER.debugf(\"ParserHook registered during template analysis: %s\", engineConfigClass);\n                    } catch (Exception e) {\n                        throw new IllegalStateException(\"Unable to instantiate ParserHook: \" + engineConfigClass, e);\n                    }\n                }\n            }\n        }\n\n        builder.computeSectionHelper(name -> {\n            // Create a dummy section helper factory for an unknown section that could be potentially registered at runtime\n            return new SectionHelperFactory<SectionHelper>() {\n                @Override\n                public SectionHelper initialize(SectionInitContext context) {\n                    return new SectionHelper() {\n                        @Override\n                        public CompletionStage<ResultNode> resolve(SectionResolutionContext context) {\n                            return ResultNode.NOOP;\n                        }\n                    };\n                }\n            };","sourceCodeStart":684,"sourceCodeEnd":720,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java#L684-L720","documentation":"Analogous to the SectionHelperFactory case: analyzeTemplates reflectively instantiates each registered ParserHook implementation via its no-arg constructor. Failure to load or instantiate (missing constructor, throwing constructor, classloading issue) aborts the build with this IllegalStateException carrying the underlying cause.","triggerScenarios":"analyzeTemplates detects a class implementing io.quarkus.qute.ParserHook among engine-config classes, loads it via tccl.loadClass() and calls getDeclaredConstructor().newInstance(); any Exception is wrapped in this IllegalStateException.","commonSituations":"ParserHook without a public no-arg constructor; hook whose constructor initializes something unavailable at build time; incompatible Qute API version on the classpath; TCCL not seeing the runtime class.","solutions":["Ensure the ParserHook has a public no-arg constructor that performs no build-time-unavailable initialization","Inspect the 'Caused by' chain for the true root cause (ClassNotFoundException vs constructor exception)","Keep the hook in a runtime module and match the Quarkus/Qute version used by the deployment module","Verify the class truly implements io.quarkus.qute.ParserHook from the platform version"],"exampleFix":"// before\npublic class MyHook implements ParserHook {\n    public MyHook(Config c) { ... } // requires args\n}\n// after\npublic class MyHook implements ParserHook {\n    public MyHook() { }\n}","handlingStrategy":"validation","validationCode":"// pre-instantiate the ParserHook to surface constructor problems early\nClass<?> c = Class.forName(\"com.acme.MyParserHook\", true, Thread.currentThread().getContextClassLoader());\nif (!io.quarkus.qute.ParserHook.class.isAssignableFrom(c)) throw new IllegalStateException(\"Not a ParserHook\");\nc.getDeclaredConstructor().newInstance(); // fails early with the real cause","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give ParserHook implementations a public no-arg constructor","Avoid heavy logic in constructors/static initializers","Verify the hook implements io.quarkus.qute.ParserHook from the same Qute version","Inspect the wrapped cause in the IllegalStateException for the root problem"],"tags":["qute","build-time","reflection","parser-hook"],"backgroundTag":"class-instantiation-failed","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"}