{"record":{"id":"54a16945c9f4daa2","repo":"quarkusio/quarkus","slug":"an-interceptor-field-cannot-be-marked-produces","errorCode":null,"errorMessage":"An interceptor field cannot be marked @Produces - ","messagePattern":"An interceptor field cannot be marked @Produces - ","errorType":"validation","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/InterceptorInfo.java","lineNumber":152,"sourceCode":"                        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(\n                            \"An interceptor field cannot be marked @Produces - \" + field + \" in class: \" + aClass);\n                }\n            }\n\n            DotName superTypeName = aClass.superName();\n            aClass = superTypeName == null || DotNames.OBJECT.equals(superTypeName) ? null\n                    : getClassByName(beanDeployment.getBeanArchiveIndex(), superTypeName);\n        }\n\n        // The interceptor methods defined by the superclasses are invoked before the interceptor method defined by the interceptor class, most general superclass first.\n        Collections.reverse(aroundInvokes);\n        Collections.reverse(postConstructs);\n        Collections.reverse(preDestroys);\n        Collections.reverse(aroundConstructs);\n\n        this.aroundInvokes = List.copyOf(aroundInvokes);\n        this.aroundConstructs = List.copyOf(aroundConstructs);\n        this.postConstructs = List.copyOf(postConstructs);","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/InterceptorInfo.java#L134-L170","documentation":"ArC throws this DefinitionException when a field of an interceptor class (or any superclass in the hierarchy walk) is annotated with @Produces. Per the CDI specification, interceptor classes must not declare producer fields, so this invalid interceptor definition is rejected during build-time bean discovery and the application fails to start.","triggerScenarios":"Annotating any field in a class used as an @Interceptor (or in its superclass) with @Produces — e.g. trying to expose a produced bean from inside an interceptor.","commonSituations":"Copy-pasting a producer field into an interceptor class; moving a @Produces field into an interceptor during refactoring; confusion between interceptor classes and regular beans.","solutions":["Remove the @Produces annotation from the field; interceptors get dependencies via @Inject constructor/field injection only.","Move the producer field to a regular CDI bean (e.g. an @ApplicationScoped class) if a producer is genuinely needed.","If the interceptor needs the produced value, @Inject the bean produced elsewhere instead of producing it inside the interceptor."],"exampleFix":"// before\n@Interceptor @Audited\nclass AuditInterceptor {\n    @Produces\n    @Named(\"auditMode\")\n    String auditMode = \"strict\";\n}\n// after\n@Interceptor @Audited\nclass AuditInterceptor {\n    @Inject\n    AuditConfig config; // inject instead of producing\n}","handlingStrategy":"validation","validationCode":"for (java.lang.reflect.Field f : AuditInterceptor.class.getFields()) {\n    if (f.isAnnotationPresent(javax.enterprise.inject.Produces.class)\n        || f.isAnnotationPresent(jakarta.enterprise.inject.Produces.class)) {\n        throw new IllegalStateException(\"@Produces not allowed on interceptor fields: \" + f);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never annotate fields in @Interceptor classes with @Produces; use @Inject for dependencies","Move producers to dedicated @ApplicationScoped producer beans","Search for @Produces in interceptor packages as a pre-build sanity check"],"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"}