{"record":{"id":"46239bb18a7fa649","repo":"quarkusio/quarkus","slug":"interceptor-declares-scope-other-than-dependent","errorCode":null,"errorMessage":"Interceptor declares scope other than @Dependent: ","messagePattern":"Interceptor declares scope other than @Dependent: ","errorType":"validation","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Interceptors.java","lineNumber":47,"sourceCode":"    }\n\n    /**\n     *\n     * @param interceptorClass\n     * @param beanDeployment\n     * @return a new interceptor info, or (only in strict mode) {@code null} if the interceptor is disabled\n     */\n    static InterceptorInfo createInterceptor(ClassInfo interceptorClass, BeanDeployment beanDeployment,\n            InjectionPointModifier transformer) {\n        Integer priority = null;\n        for (AnnotationInstance annotation : beanDeployment.getAnnotations(interceptorClass)) {\n            if (annotation.name().equals(DotNames.PRIORITY)) {\n                priority = annotation.value().asInt();\n            }\n            // rudimentary, but good enough for now (should also look at inherited annotations and stereotypes)\n            ScopeInfo scope = beanDeployment.getScope(annotation.name());\n            if (scope != null && !BuiltinScope.DEPENDENT.is(scope)) {\n                throw new DefinitionException(\"Interceptor declares scope other than @Dependent: \" + interceptorClass);\n            }\n        }\n\n        Set<AnnotationInstance> bindings = new HashSet<>();\n        addBindings(beanDeployment, interceptorClass, bindings, false);\n\n        if (bindings.isEmpty()) {\n            throw new DefinitionException(\"Interceptor has no bindings: \" + interceptorClass);\n        }\n\n        if (priority == null) {\n            if (beanDeployment.strictCompatibility) {\n                // interceptor without `@Priority` is disabled per the specification\n                return null;\n            }\n\n            LOGGER.info(\"The interceptor \" + interceptorClass + \" does not declare any @Priority. \" +\n                    \"It will be assigned a default priority value of 0.\");","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Interceptors.java#L29-L65","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n@ApplicationScoped\n@Interceptor\n@Logged\nclass LoggingInterceptor { }\n// after\n@Dependent\n@Interceptor\n@Logged\nclass LoggingInterceptor { }","handlingStrategy":"validation","validationCode":"for (java.lang.annotation.Annotation a : LoggingInterceptor.class.getAnnotations()) {\n    if (a.annotationType().isAnnotationPresent(jakarta.enterprise.context.NormalScope.class)\n        && a.annotationType() != jakarta.enterprise.context.Dependent.class) {\n        throw new IllegalStateException(\"Interceptor must be @Dependent, found: \" + a);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cdi","quarkus","arc","interceptor","scope"],"backgroundTag":"illegal-interceptor-scope","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"}