quarkusio/quarkus · error · DefinitionException

Field ${field} of class ${beanClass} is not a producer field

Error message

Field ${field} of class ${beanClass} is not a producer field, but is annotated with a stereotype: ${stereotype}

What it means

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.

Source

Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java:1326

                    // Producer fields are not inherited
                    if (strictCompatibility) {
                        if (hasBeanDefiningAnnotation) {
                            producerFields.add(field);
                        }
                    } else {
                        producerFields.add(field);
                        if (!hasBeanDefiningAnnotation) {
                            LOGGER.debugf("Producer field found but %s has no bean defining annotation - using @Dependent",
                                    beanClass);
                            beanClasses.add(beanClass);
                        }
                    }
                } else if (!annotationStore.hasAnnotation(field, DotNames.PRODUCES)) {
                    // Verify that non-producer fields are not annotated with stereotypes
                    // (vetoed producers must _not_ be checked)
                    for (AnnotationInstance i : annotationStore.getAnnotations(field)) {
                        if (realStereotypes.contains(i.name())) {
                            throw new DefinitionException(
                                    "Field " + field + " of class " + beanClass
                                            + " is not a producer field, but is annotated " +
                                            "with a stereotype: " + i.name().toString());
                        }
                    }
                }
            }
        }

        // Build metadata for typesafe resolution
        List<BeanInfo> beans = new ArrayList<>();
        Map<ClassInfo, BeanInfo> beanClassToBean = new HashMap<>();
        for (ClassInfo beanClass : beanClasses) {
            BeanInfo classBean = Beans.createClassBean(beanClass, this, injectionPointTransformer);
            if (classBean != null) {
                beans.add(classBean);
                beanClassToBean.put(beanClass, classBean);
                injectionPoints.addAll(classBean.getAllInjectionPoints());

View on GitHub (pinned to e1c734241f)

Solutions

  1. Remove the stereotype annotation from the field.
  2. Add @Produces if the field is intended to expose a bean.
  3. Restrict the stereotype's @Target to TYPE so it cannot be applied to fields.

Example fix

// before
class Service {
  @Transactional
  String cacheKey = "k"; // stereotype on non-producer field
}
// after
class Service {
  String cacheKey = "k";
}
Defensive patterns

Strategy: validation

Validate before calling

if (!field.isAnnotationPresent(Produces.class)
        && Arrays.stream(field.getAnnotations()).anyMatch(a -> a.annotationType().isAnnotationPresent(Stereotype.class))) {
    throw new IllegalStateException("Stereotype on non-producer field: " + field);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/c9b496f7605f64c6. Report an issue: GitHub.