quarkusio/quarkus · error · DefinitionException
Interceptor declares scope other than @Dependent:
Error message
Interceptor declares scope other than @Dependent:
What it means
ArC throws this DefinitionException when an @Interceptor class declares a scope annotation other than @Dependent. Interceptors are always dependent-scoped per the CDI specification — they share the lifecycle of the bean they intercept and cannot have their own normal scope. Detected at build time during interceptor creation, aborting deployment.
Source
Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Interceptors.java:47
}
/**
*
* @param interceptorClass
* @param beanDeployment
* @return a new interceptor info, or (only in strict mode) {@code null} if the interceptor is disabled
*/
static InterceptorInfo createInterceptor(ClassInfo interceptorClass, BeanDeployment beanDeployment,
InjectionPointModifier transformer) {
Integer priority = null;
for (AnnotationInstance annotation : beanDeployment.getAnnotations(interceptorClass)) {
if (annotation.name().equals(DotNames.PRIORITY)) {
priority = annotation.value().asInt();
}
// rudimentary, but good enough for now (should also look at inherited annotations and stereotypes)
ScopeInfo scope = beanDeployment.getScope(annotation.name());
if (scope != null && !BuiltinScope.DEPENDENT.is(scope)) {
throw new DefinitionException("Interceptor declares scope other than @Dependent: " + interceptorClass);
}
}
Set<AnnotationInstance> bindings = new HashSet<>();
addBindings(beanDeployment, interceptorClass, bindings, false);
if (bindings.isEmpty()) {
throw new DefinitionException("Interceptor has no bindings: " + interceptorClass);
}
if (priority == null) {
if (beanDeployment.strictCompatibility) {
// interceptor without `@Priority` is disabled per the specification
return null;
}
LOGGER.info("The interceptor " + interceptorClass + " does not declare any @Priority. " +
"It will be assigned a default priority value of 0.");View on GitHub (pinned to e1c734241f)
Solutions
- Remove the scope annotation from the interceptor class, or replace it with @Dependent.
- If the interceptor needs scoped state, store state in an injected @Dependent or scoped helper bean instead.
- If you meant a regular bean, remove the @Interceptor and its @InterceptorBinding annotations.
Example fix
// before
@ApplicationScoped
@Interceptor
@Logged
class LoggingInterceptor { }
// after
@Dependent
@Interceptor
@Logged
class LoggingInterceptor { } Defensive patterns
Strategy: validation
Validate before calling
for (java.lang.annotation.Annotation a : LoggingInterceptor.class.getAnnotations()) {
if (a.annotationType().isAnnotationPresent(jakarta.enterprise.context.NormalScope.class)
&& a.annotationType() != jakarta.enterprise.context.Dependent.class) {
throw new IllegalStateException("Interceptor must be @Dependent, found: " + a);
}
} Prevention
- Always declare interceptors as @Dependent (or with no scope annotation)
- Never copy scope annotations from regular beans onto interceptors
- If stateful behavior is needed, delegate to an injected scoped bean
When it happens
Trigger: Annotating an @Interceptor class with @ApplicationScoped, @RequestScoped, @SessionScoped, or any other normal scope. The check is rudimentary: it looks at the interceptor's annotations and rejects any recognized scope that is not @Dependent.
Common situations: Copy-pasting annotations from a regular bean to an interceptor; adding a scope annotation to fix an unrelated injection warning; misunderstanding that interceptors must always be @Dependent.
Related errors
- A decorator must be @Dependent but ${decoratorClass} declare
- Multiple @AroundInvoke interceptor methods declared on class
- Multiple @AroundConstruct interceptor methods declared on cl
- Multiple @PostConstruct interceptor methods declared on clas
- Multiple @PreDestroy interceptor methods declared on class:
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/46239bb18a7fa649.
Report an issue: GitHub.