{"record":{"id":"8ad259e55e6e6be9","repo":"quarkusio/quarkus","slug":"multiple-postconstruct-interceptor-methods-declar","errorCode":null,"errorMessage":"Multiple @PostConstruct interceptor methods declared on class: ","messagePattern":"Multiple @PostConstruct interceptor methods declared on class: ","errorType":"validation","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/InterceptorInfo.java","lineNumber":134,"sourceCode":"                            InterceptorPlacement.INTERCEPTOR_CLASS);\n                    if (++aroundInvokesFound > 1) {\n                        throw new DefinitionException(\n                                \"Multiple @AroundInvoke interceptor methods declared on class: \" + aClass);\n                    }\n                }\n                if (store.hasAnnotation(method, DotNames.AROUND_CONSTRUCT)) {\n                    addInterceptorMethod(allMethods, aroundConstructs, method, InterceptionType.AROUND_CONSTRUCT,\n                            InterceptorPlacement.INTERCEPTOR_CLASS);\n                    if (++aroundConstructsFound > 1) {\n                        throw new DefinitionException(\n                                \"Multiple @AroundConstruct interceptor methods declared on class: \" + aClass);\n                    }\n                }\n                if (store.hasAnnotation(method, DotNames.POST_CONSTRUCT)) {\n                    addInterceptorMethod(allMethods, postConstructs, method, InterceptionType.POST_CONSTRUCT,\n                            InterceptorPlacement.INTERCEPTOR_CLASS);\n                    if (++postConstructsFound > 1) {\n                        throw new DefinitionException(\n                                \"Multiple @PostConstruct interceptor methods declared on class: \" + aClass);\n                    }\n                }\n                if (store.hasAnnotation(method, DotNames.PRE_DESTROY)) {\n                    addInterceptorMethod(allMethods, preDestroys, method, InterceptionType.PRE_DESTROY,\n                            InterceptorPlacement.INTERCEPTOR_CLASS);\n                    if (++preDestroysFound > 1) {\n                        throw new DefinitionException(\n                                \"Multiple @PreDestroy interceptor methods declared on class: \" + aClass);\n                    }\n                }\n                allMethods.add(method);\n            }\n\n            for (FieldInfo field : aClass.fields()) {\n                if (store.hasAnnotation(field, DotNames.PRODUCES)) {\n                    // according to spec, finding @Produces on a field is a DefinitionException\n                    throw new DefinitionException(","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/InterceptorInfo.java#L116-L152","documentation":"ArC throws this DefinitionException when an interceptor class (or any one class in its hierarchy) declares more than one non-static method annotated with @PostConstruct. The CDI specification allows at most one @PostConstruct lifecycle callback interceptor method per interceptor class. The error is raised during build-time bean discovery, preventing the application from starting.","triggerScenarios":"Two or more non-static methods annotated with @PostConstruct in the same interceptor class. The count resets for each class in the hierarchy, so one per class across superclass/subclass is permitted.","commonSituations":"Migrating from Spring (where multiple @PostConstruct-like init methods were tolerated via @Bean initMethod) to CDI; merging interceptor classes; copy-paste during refactoring.","solutions":["Keep a single @PostConstruct method and call the other initialization methods from it as plain helpers.","Remove the @PostConstruct annotation from the redundant method.","Use @ApplicationScoped/@Dependent bean lifecycle callbacks elsewhere, or split into multiple interceptor classes."],"exampleFix":"// before\nclass MyInterceptor {\n    @PostConstruct void init1(InvocationContext ctx) throws Exception { ctx.proceed(); }\n    @PostConstruct void init2(InvocationContext ctx) throws Exception { ctx.proceed(); }\n}\n// after\nclass MyInterceptor {\n    @PostConstruct void init(InvocationContext ctx) throws Exception { extraInit(); ctx.proceed(); }\n    void extraInit() { /* ... */ }\n}","handlingStrategy":"validation","validationCode":"long n = java.util.Arrays.stream(MyInterceptor.class.getDeclaredMethods())\n    .filter(m -> m.isAnnotationPresent(jakarta.annotation.PostConstruct.class))\n    .count();\nif (n > 1) throw new IllegalStateException(\"Only one @PostConstruct allowed per interceptor class\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One @PostConstruct per class; chain other init methods from it","When migrating from Spring-style multiple init methods, consolidate them first","Audit superclasses: each class level may hold one callback, but one class may not hold two"],"tags":["cdi","quarkus","arc","interceptor","lifecycle"],"backgroundTag":"multiple-interceptor-methods","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"}