{"record":{"id":"3d442152116692c7","repo":"quarkusio/quarkus","slug":"interceptor-declares-a-producer-method","errorCode":null,"errorMessage":"Interceptor declares a producer method: ","messagePattern":"Interceptor declares a producer method: ","errorType":"validation","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Interceptors.java","lineNumber":142,"sourceCode":"\n                    if (!value.equals(binding.valueWithDefault(index, value.name()))) {\n                        throw new DefinitionException(\"Multiple instances of non-repeatable interceptor binding annotation \"\n                                + name + \" with different member values on class \" + targetClass);\n                    }\n                }\n            } else {\n                // interceptor binding of that type not seen yet, just remember it\n                seenBindings.put(name, binding.valuesWithDefaults(index));\n            }\n        }\n    }\n\n    private static void checkInterceptorFieldsAndMethods(ClassInfo interceptorClass, BeanDeployment beanDeployment) {\n        ClassInfo aClass = interceptorClass;\n        while (aClass != null) {\n            for (MethodInfo method : aClass.methods()) {\n                if (beanDeployment.hasAnnotation(method, DotNames.PRODUCES)) {\n                    throw new DefinitionException(\"Interceptor declares a producer method: \" + interceptorClass);\n                }\n                // the following 3 checks rely on the annotation store returning parameter annotations for methods\n                if (beanDeployment.hasAnnotation(method, DotNames.DISPOSES)) {\n                    throw new DefinitionException(\"Interceptor declares a disposer method: \" + interceptorClass);\n                }\n                if (beanDeployment.hasAnnotation(method, DotNames.OBSERVES)) {\n                    throw new DefinitionException(\"Interceptor declares an observer method: \" + interceptorClass);\n                }\n                if (beanDeployment.hasAnnotation(method, DotNames.OBSERVES_ASYNC)) {\n                    throw new DefinitionException(\"Interceptor declares an async observer method: \" + interceptorClass);\n                }\n            }\n\n            for (FieldInfo field : aClass.fields()) {\n                if (beanDeployment.hasAnnotation(field, DotNames.PRODUCES)) {\n                    throw new DefinitionException(\"Interceptor declares a producer field: \" + interceptorClass);\n                }\n            }","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Interceptors.java#L124-L160","documentation":"ArC throws this DefinitionException when an interceptor class (or any class in its superclass hierarchy) declares a method annotated with @Produces. Per the CDI specification, interceptors cannot declare producer methods — they are not beans that can produce other beans. The check runs over the whole class hierarchy at build time, aborting deployment.","triggerScenarios":"Annotating a method with @Produces in a class carrying @Interceptor (including inherited methods found in the hierarchy walk). Related sibling checks reject @Disposes and @Observes methods similarly.","commonSituations":"Copy-pasting a producer method into an interceptor class; converting a regular CDI bean into an interceptor without removing its producers; misunderstanding that interceptors may only have injection points and interceptor methods.","solutions":["Remove the @Produces annotation from the method inside the interceptor.","Move the producer method to a regular CDI bean (e.g. an @ApplicationScoped class) if the produced bean is genuinely needed.","Have the interceptor @Inject the produced bean instead of producing it."],"exampleFix":"// before\n@Interceptor @Audited\nclass AuditInterceptor {\n    @Produces\n    AuditRecorder recorder() { return new AuditRecorder(); }\n}\n// after\n@Interceptor @Audited\nclass AuditInterceptor {\n    @Inject\n    AuditRecorder recorder; // producer lives in a separate bean\n}","handlingStrategy":"validation","validationCode":"for (java.lang.reflect.Method m : AuditInterceptor.class.getMethods()) {\n    if (m.isAnnotationPresent(jakarta.enterprise.inject.Produces.class)\n        || m.isAnnotationPresent(jakarta.enterprise.inject.Disposes.class)) {\n        throw new IllegalStateException(\"Interceptor cannot declare producer/disposer: \" + m);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never place @Produces, @Disposes or @Observes methods in @Interceptor classes","Move producer methods to dedicated producer beans","When converting beans to interceptors, strip producer/disposer/observer members first"],"tags":["cdi","quarkus","arc","interceptor","producer"],"backgroundTag":"illegal-interceptor-member","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"}