{"record":{"id":"c9b496f7605f64c6","repo":"quarkusio/quarkus","slug":"field-field-of-class-beanclass-is-not-a-prod","errorCode":null,"errorMessage":"Field ${field} of class ${beanClass} is not a producer field, but is annotated with a stereotype: ${stereotype}","messagePattern":"Field (.+?) of class (.+?) is not a producer field, but is annotated with a stereotype: (.+?)","errorType":"exception","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java","lineNumber":1326,"sourceCode":"                    // Producer fields are not inherited\n                    if (strictCompatibility) {\n                        if (hasBeanDefiningAnnotation) {\n                            producerFields.add(field);\n                        }\n                    } else {\n                        producerFields.add(field);\n                        if (!hasBeanDefiningAnnotation) {\n                            LOGGER.debugf(\"Producer field found but %s has no bean defining annotation - using @Dependent\",\n                                    beanClass);\n                            beanClasses.add(beanClass);\n                        }\n                    }\n                } else if (!annotationStore.hasAnnotation(field, DotNames.PRODUCES)) {\n                    // Verify that non-producer fields are not annotated with stereotypes\n                    // (vetoed producers must _not_ be checked)\n                    for (AnnotationInstance i : annotationStore.getAnnotations(field)) {\n                        if (realStereotypes.contains(i.name())) {\n                            throw new DefinitionException(\n                                    \"Field \" + field + \" of class \" + beanClass\n                                            + \" is not a producer field, but is annotated \" +\n                                            \"with a stereotype: \" + i.name().toString());\n                        }\n                    }\n                }\n            }\n        }\n\n        // Build metadata for typesafe resolution\n        List<BeanInfo> beans = new ArrayList<>();\n        Map<ClassInfo, BeanInfo> beanClassToBean = new HashMap<>();\n        for (ClassInfo beanClass : beanClasses) {\n            BeanInfo classBean = Beans.createClassBean(beanClass, this, injectionPointTransformer);\n            if (classBean != null) {\n                beans.add(classBean);\n                beanClassToBean.put(beanClass, classBean);\n                injectionPoints.addAll(classBean.getAllInjectionPoints());","sourceCodeStart":1308,"sourceCodeEnd":1344,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java#L1308-L1344","documentation":"Stereotypes may only be placed on producer fields or on bean classes; a non-producer field carrying a real stereotype annotation is rejected with this DefinitionException during bean discovery. Vetoed producers are deliberately excluded from the check.","triggerScenarios":"A field without @Produces on a bean class is annotated with a stereotype contained in realStereotypes; BeanDeployment.deploy scans field annotations while registering the bean.","commonSituations":"Adding @Transactional or a custom stereotype to a plain constant/helper field; bulk-adding stereotypes to all members of a class; refactoring removed @Produces but kept the stereotype.","solutions":["Remove the stereotype annotation from the field.","Add @Produces if the field is intended to expose a bean.","Restrict the stereotype's @Target to TYPE so it cannot be applied to fields."],"exampleFix":"// before\nclass Service {\n  @Transactional\n  String cacheKey = \"k\"; // stereotype on non-producer field\n}\n// after\nclass Service {\n  String cacheKey = \"k\";\n}","handlingStrategy":"validation","validationCode":"if (!field.isAnnotationPresent(Produces.class)\n        && Arrays.stream(field.getAnnotations()).anyMatch(a -> a.annotationType().isAnnotationPresent(Stereotype.class))) {\n    throw new IllegalStateException(\"Stereotype on non-producer field: \" + field);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep stereotypes off plain fields","Restrict stereotype @Target to TYPE and METHOD when fields are not intended","Audit annotations after removing @Produces from a field"],"tags":["cdi","quarkus-arc","stereotype","field"],"backgroundTag":"stereotype-on-non-producer","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"}