{"record":{"id":"eb55e62f3e0a0d56","repo":"quarkusio/quarkus","slug":"multiple-aroundconstruct-interceptor-methods-decl","errorCode":null,"errorMessage":"Multiple @AroundConstruct interceptor methods declared on class: ","messagePattern":"Multiple @AroundConstruct 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":126,"sourceCode":"                if (store.hasAnnotation(method, DotNames.PRODUCES) || store.hasAnnotation(method, DotNames.DISPOSES)) {\n                    // according to spec, finding @Produces or @Disposes on a method is a DefinitionException\n                    throw new DefinitionException(\n                            \"An interceptor method cannot be marked @Produces or @Disposes - \" + method + \" in class: \"\n                                    + aClass);\n                }\n                if (store.hasAnnotation(method, DotNames.AROUND_INVOKE)) {\n                    addInterceptorMethod(allMethods, aroundInvokes, method, InterceptionType.AROUND_INVOKE,\n                            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                    }","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/InterceptorInfo.java#L108-L144","documentation":"ArC throws this DefinitionException when an interceptor class (or a single class in its hierarchy) declares more than one non-static method annotated with @AroundConstruct. The CDI specification permits at most one @AroundConstruct interceptor method per interceptor class. The failure happens during bean discovery, so the application does not compile/deploy successfully.","triggerScenarios":"Declaring two or more non-static @AroundConstruct methods in the same interceptor class. Note the per-class counter: one @AroundConstruct in a superclass plus one in the subclass is legal; two in the same class are not.","commonSituations":"Copy-pasting an @AroundConstruct method when extending a base interceptor; accidentally annotating both a constructor-interception wrapper and a legacy method during migration from javax to jakarta annotations.","solutions":["Keep exactly one @AroundConstruct method per interceptor class and move the extra logic into an unannotated helper method called from it.","Remove the duplicate @AroundConstruct annotation if the method is no longer needed.","Split into separate interceptor classes if the constructor interception concerns should be independent."],"exampleFix":"// before\nclass MyInterceptor {\n    @AroundConstruct void init1(InvocationContext ctx) throws Exception { ctx.proceed(); }\n    @AroundConstruct void init2(InvocationContext ctx) throws Exception { ctx.proceed(); }\n}\n// after\nclass MyInterceptor {\n    @AroundConstruct void init(InvocationContext ctx) throws Exception { ctx.proceed(); }\n}","handlingStrategy":"validation","validationCode":"long n = java.util.Arrays.stream(MyInterceptor.class.getDeclaredMethods())\n    .filter(m -> m.isAnnotationPresent(jakarta.interceptor.AroundConstruct.class))\n    .count();\nif (n > 1) throw new IllegalStateException(\"Only one @AroundConstruct allowed per interceptor class\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare exactly one @AroundConstruct method per interceptor class","Delegate secondary constructor logic to unannotated helper methods","Re-check after refactors that merge interceptor classes"],"tags":["cdi","quarkus","arc","interceptor","build-time"],"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-14T00:17:10.932Z"}