quarkusio/quarkus · error · DefinitionException

Interceptor declares a producer method:

Error message

Interceptor declares a producer method: 

What it means

ArC throws this DefinitionException when an interceptor class (or any class in its superclass hierarchy) declares a method annotated with @Produces. Per the CDI specification, interceptors cannot declare producer methods — they are not beans that can produce other beans. The check runs over the whole class hierarchy at build time, aborting deployment.

Source

Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Interceptors.java:142

                    if (!value.equals(binding.valueWithDefault(index, value.name()))) {
                        throw new DefinitionException("Multiple instances of non-repeatable interceptor binding annotation "
                                + name + " with different member values on class " + targetClass);
                    }
                }
            } else {
                // interceptor binding of that type not seen yet, just remember it
                seenBindings.put(name, binding.valuesWithDefaults(index));
            }
        }
    }

    private static void checkInterceptorFieldsAndMethods(ClassInfo interceptorClass, BeanDeployment beanDeployment) {
        ClassInfo aClass = interceptorClass;
        while (aClass != null) {
            for (MethodInfo method : aClass.methods()) {
                if (beanDeployment.hasAnnotation(method, DotNames.PRODUCES)) {
                    throw new DefinitionException("Interceptor declares a producer method: " + interceptorClass);
                }
                // the following 3 checks rely on the annotation store returning parameter annotations for methods
                if (beanDeployment.hasAnnotation(method, DotNames.DISPOSES)) {
                    throw new DefinitionException("Interceptor declares a disposer method: " + interceptorClass);
                }
                if (beanDeployment.hasAnnotation(method, DotNames.OBSERVES)) {
                    throw new DefinitionException("Interceptor declares an observer method: " + interceptorClass);
                }
                if (beanDeployment.hasAnnotation(method, DotNames.OBSERVES_ASYNC)) {
                    throw new DefinitionException("Interceptor declares an async observer method: " + interceptorClass);
                }
            }

            for (FieldInfo field : aClass.fields()) {
                if (beanDeployment.hasAnnotation(field, DotNames.PRODUCES)) {
                    throw new DefinitionException("Interceptor declares a producer field: " + interceptorClass);
                }
            }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Remove the @Produces annotation from the method inside the interceptor.
  2. Move the producer method to a regular CDI bean (e.g. an @ApplicationScoped class) if the produced bean is genuinely needed.
  3. Have the interceptor @Inject the produced bean instead of producing it.

Example fix

// before
@Interceptor @Audited
class AuditInterceptor {
    @Produces
    AuditRecorder recorder() { return new AuditRecorder(); }
}
// after
@Interceptor @Audited
class AuditInterceptor {
    @Inject
    AuditRecorder recorder; // producer lives in a separate bean
}
Defensive patterns

Strategy: validation

Validate before calling

for (java.lang.reflect.Method m : AuditInterceptor.class.getMethods()) {
    if (m.isAnnotationPresent(jakarta.enterprise.inject.Produces.class)
        || m.isAnnotationPresent(jakarta.enterprise.inject.Disposes.class)) {
        throw new IllegalStateException("Interceptor cannot declare producer/disposer: " + m);
    }
}

Prevention

When it happens

Trigger: Annotating a method with @Produces in a class carrying @Interceptor (including inherited methods found in the hierarchy walk). Related sibling checks reject @Disposes and @Observes methods similarly.

Common situations: Copy-pasting a producer method into an interceptor class; converting a regular CDI bean into an interceptor without removing its producers; misunderstanding that interceptors may only have injection points and interceptor methods.

Related errors


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