{"record":{"id":"ef1ac65fcaf391fa","repo":"quarkusio/quarkus","slug":"a-decorator-must-be-dependent-but-decoratorclas","errorCode":null,"errorMessage":"A decorator must be @Dependent but ${decoratorClass} declares ${scopeAnnotation.getDotName()}","messagePattern":"A decorator must be @Dependent but (.+?) declares (.+?)","errorType":"exception","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Decorators.java","lineNumber":67,"sourceCode":"            }\n        }\n        if (delegateInjectionPoints.isEmpty()) {\n            throw new DefinitionException(\"The decorator \" + decoratorClass + \" has no @Delegate injection point\");\n        } else if (delegateInjectionPoints.size() > 1) {\n            throw new DefinitionException(\n                    \"The decorator \" + decoratorClass + \" has multiple @Delegate injection points: \" + delegateInjectionPoints);\n        }\n\n        InjectionPointInfo delegateInjectionPoint = delegateInjectionPoints.get(0);\n\n        Integer priority = null;\n        for (AnnotationInstance annotation : beanDeployment.getAnnotations(decoratorClass)) {\n            if (annotation.name().equals(DotNames.PRIORITY)) {\n                priority = annotation.value().asInt();\n            }\n            ScopeInfo scopeAnnotation = beanDeployment.getScope(annotation.name());\n            if (scopeAnnotation != null && !BuiltinScope.DEPENDENT.is(scopeAnnotation)) {\n                throw new DefinitionException(\n                        \"A decorator must be @Dependent but \" + decoratorClass + \" declares \" + scopeAnnotation.getDotName());\n            }\n        }\n\n        //  The set includes all bean types which are Java interfaces, except for java.io.Serializable\n        TypeClosure typeClosure = Types.getClassBeanTypeClosure(decoratorClass, beanDeployment);\n        Set<Type> types = typeClosure.types();\n        Set<Type> decoratedTypes = new HashSet<>();\n        for (Type type : types) {\n            if (type.name().equals(DotNames.SERIALIZABLE)) {\n                continue;\n            }\n            ClassInfo clazz = beanDeployment.getBeanArchiveIndex().getClassByName(type.name());\n            if (Modifier.isInterface(clazz.flags())) {\n                decoratedTypes.add(type);\n            }\n        }\n        if (decoratedTypes.isEmpty()) {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Decorators.java#L49-L85","documentation":"Per CDI, a decorator must be a @Dependent-scoped bean. During Decorators.createDecorator, Arc scans the decorator class annotations; if it finds a scope annotation other than @Dependent (e.g. @ApplicationScoped), it throws this DefinitionException.","triggerScenarios":"Annotating a @Decorator class with @ApplicationScoped, @RequestScoped, @Singleton or any other normal/psuedo scope instead of @Dependent.","commonSituations":"IDE auto-adding a scope annotation; copying a regular bean class and adding @Decorator without removing @ApplicationScoped; misunderstanding that decorators inherit scope.","solutions":["Remove the scope annotation so the decorator defaults to @Dependent, or explicitly annotate @Dependent","If scoped behavior is required, move state into the decorated bean or a separate bean the decorator delegates through"],"exampleFix":"// before\n@Decorator\n@ApplicationScoped\npublic class MyDecorator implements MyIface { ... }\n// after\n@Decorator\n@Dependent\npublic class MyDecorator implements MyIface { ... }","handlingStrategy":"validation","validationCode":"static void requireDependentScope(Class<?> decorator) {\n  for (var a : decorator.getAnnotations()) {\n    if (a.annotationType().isAnnotationPresent(jakarta.enterprise.context.NormalScope.class)\n        || a.annotationType().isAnnotationPresent(jakarta.inject.Scope.class)) {\n      if (a.annotationType() != jakarta.enterprise.context.Dependent.class)\n        throw new IllegalStateException(\"Decorator must be @Dependent: \" + a);\n    }\n  }\n}","typeGuard":"static boolean isDependentScoped(Class<?> decorator) {\n  return decorator.isAnnotationPresent(jakarta.enterprise.context.Dependent.class)\n      || java.util.Arrays.stream(decorator.getAnnotations()).noneMatch(a ->\n          a.annotationType().isAnnotationPresent(jakarta.enterprise.context.NormalScope.class)\n          || a.annotationType().isAnnotationPresent(jakarta.inject.Scope.class));\n}","tryCatchPattern":null,"preventionTips":["Never add scope annotations to @Decorator classes","Review IDE quick-fixes that suggest adding @ApplicationScoped to new classes"],"tags":["quarkus","arc","cdi","decorator","scope"],"backgroundTag":"decorator-scope-not-dependent","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"}