{"record":{"id":"47f3b4d960ce982a","repo":"quarkusio/quarkus","slug":"decorator-declares-a-producer-field-decoratorcl","errorCode":null,"errorMessage":"Decorator declares a producer field: ${decoratorClass}","messagePattern":"Decorator declares a producer field: (.+?)","errorType":"exception","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Decorators.java","lineNumber":180,"sourceCode":"            for (MethodInfo method : aClass.methods()) {\n                if (beanDeployment.hasAnnotation(method, DotNames.PRODUCES)) {\n                    throw new DefinitionException(\"Decorator declares a producer method: \" + decoratorClass);\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(\"Decorator declares a disposer method: \" + decoratorClass);\n                }\n                if (beanDeployment.hasAnnotation(method, DotNames.OBSERVES)) {\n                    throw new DefinitionException(\"Decorator declares an observer method: \" + decoratorClass);\n                }\n                if (beanDeployment.hasAnnotation(method, DotNames.OBSERVES_ASYNC)) {\n                    throw new DefinitionException(\"Decorator declares an async observer method: \" + decoratorClass);\n                }\n            }\n\n            for (FieldInfo field : aClass.fields()) {\n                if (beanDeployment.hasAnnotation(field, DotNames.PRODUCES)) {\n                    throw new DefinitionException(\"Decorator declares a producer field: \" + decoratorClass);\n                }\n            }\n\n            DotName superClass = aClass.superName();\n            aClass = superClass != null && !superClass.equals(DotNames.OBJECT)\n                    ? getClassByName(beanDeployment.getBeanArchiveIndex(), superClass)\n                    : null;\n        }\n    }\n\n}\n","sourceCodeStart":162,"sourceCodeEnd":192,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Decorators.java#L162-L192","documentation":"Build-time CDI definition error: while validating the decorator class, ArC found a field annotated @Produces. Producer fields are forbidden in decorators (decoration happens through the @Delegate injection point only), so the deployment aborts naming the decorator.","triggerScenarios":"A @Decorator class declares a field annotated @Produces, detected during createDecorator's field validation.","commonSituations":"Class converted from a producer bean into a decorator with the producer field left in place; copy-paste; moving production logic into a decorator by mistake.","solutions":["Remove the @Produces field from the decorator.","Move the producer field to a separate non-decorator bean and inject it where needed.","Remove @Decorator if the class was really meant to be a producer bean.","Inspect parent classes as the check walks the hierarchy."],"exampleFix":"// before\n@Decorator\npublic class D implements Greeter {\n    @Produces\n    Helper helper = new Helper();\n}\n\n// after\n@Decorator\npublic class D implements Greeter {\n    @Inject Helper helper; // produced by another bean\n}","handlingStrategy":"validation","validationCode":"if (decoratorClass.getAnnotation(jakarta.decorator.Decorator.class) != null)\n    for (Field f : decoratorClass.getFields())\n        if (f.isAnnotationPresent(jakarta.enterprise.inject.Produces.class))\n            throw new IllegalStateException(\"Decorator cannot declare producer field: \" + f);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never annotate fields with @Produces inside a decorator.","Move producer fields to a separate @ApplicationScoped producer bean."],"tags":["cdi","decorator","producer","illegal-annotation"],"backgroundTag":"illegal-annotation-on-decorator","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"}