quarkusio/quarkus · error · DefinitionException

The decorator ${decoratorClass} has no @Delegate injection p

Error message

The decorator ${decoratorClass} has no @Delegate injection point

What it means

A CDI decorator must declare exactly one @Delegate injection point designating the object it decorates. Arc's Decorators.createDecorator raises a DefinitionException when the decorator class declares none.

Source

Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Decorators.java:52

     * @param transformer
     * @return a new decorator info, or (only in strict mode) {@code null} if the decorator is disabled
     */
    static DecoratorInfo createDecorator(ClassInfo decoratorClass, BeanDeployment beanDeployment,
            InjectionPointModifier transformer) {

        // Find the delegate injection point
        List<InjectionPointInfo> delegateInjectionPoints = new ArrayList<>();
        List<Injection> injections = Injection.forBean(decoratorClass, null, beanDeployment, transformer,
                Injection.BeanType.DECORATOR);
        for (Injection injection : injections) {
            for (InjectionPointInfo injectionPoint : injection.injectionPoints) {
                if (injectionPoint.isDelegate()) {
                    delegateInjectionPoints.add(injectionPoint);
                }
            }
        }
        if (delegateInjectionPoints.isEmpty()) {
            throw new DefinitionException("The decorator " + decoratorClass + " has no @Delegate injection point");
        } else if (delegateInjectionPoints.size() > 1) {
            throw new DefinitionException(
                    "The decorator " + decoratorClass + " has multiple @Delegate injection points: " + delegateInjectionPoints);
        }

        InjectionPointInfo delegateInjectionPoint = delegateInjectionPoints.get(0);

        Integer priority = null;
        for (AnnotationInstance annotation : beanDeployment.getAnnotations(decoratorClass)) {
            if (annotation.name().equals(DotNames.PRIORITY)) {
                priority = annotation.value().asInt();
            }
            ScopeInfo scopeAnnotation = beanDeployment.getScope(annotation.name());
            if (scopeAnnotation != null && !BuiltinScope.DEPENDENT.is(scopeAnnotation)) {
                throw new DefinitionException(
                        "A decorator must be @Dependent but " + decoratorClass + " declares " + scopeAnnotation.getDotName());
            }
        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add a field of the decorated type annotated with @Delegate (jakarta.enterprise.inject.spi/documentation-consistent import: jakarta.inject / jakarta.enterprise decorators use @Delegate from jakarta.enterprise.inject.spi? use io.quarkus/jakarta @Delegate)
  2. Verify the annotation import resolves to jakarta/enterprise Delegate, not a custom class
  3. Ensure exactly one delegate field exists (see companion error for multiples)

Example fix

// before
public class AuditDecorator implements Audited { public void audit() {...} }
// after
@Decorator
public class AuditDecorator implements Audited {
  @Delegate @Inject Audited delegate;
  public void audit() { delegate.audit(); }
}
Defensive patterns

Strategy: validation

Validate before calling

static void requireDelegate(Class<?> decorator) {
  long n = java.util.Arrays.stream(decorator.getDeclaredFields())
      .filter(f -> f.isAnnotationPresent(jakarta.decorator.Delegate.class)).count();
  if (n == 0) throw new IllegalStateException(decorator + " has no @Delegate injection point");
}

Type guard

static boolean hasDelegate(java.lang.reflect.Field[] fields) {
  return java.util.Arrays.stream(fields)
      .anyMatch(f -> f.isAnnotationPresent(jakarta.decorator.Delegate.class));
}

Prevention

When it happens

Trigger: Implementing a decorator class whose @Delegate-annotated field is missing, misnamed annotation (e.g. import of wrong @Delegate), or whose delegate field was removed/renamed; decorator registered but implementing only the interface.

Common situations: Forgetting @Delegate after refactoring; importing jakarta Decorator but not annotating the field; copying a decorator example but dropping the delegate field; wrong package import of @Delegate.

Related errors


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