{"record":{"id":"2be18c3aac455dff","repo":"flowable/flowable-engine","slug":"scopedassociation-must-carry-exactly-one-annotatio","errorCode":null,"errorMessage":"ScopedAssociation must carry exactly one annotation and it must be a @Scope annotation","messagePattern":"ScopedAssociation must carry exactly one annotation and it must be a @Scope annotation","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cdi/src/main/java/org/flowable/cdi/impl/context/DefaultContextAssociationManager.java","lineNumber":114,"sourceCode":"\r\n    }\r\n\r\n    @ConversationScoped\r\n    protected static class ConversationScopedAssociation extends ScopedAssociation implements Serializable {\r\n    }\r\n\r\n    @RequestScoped\r\n    protected static class RequestScopedAssociation extends ScopedAssociation implements Serializable {\r\n    }\r\n\r\n    @Inject\r\n    private BeanManager beanManager;\r\n\r\n    protected Class<? extends ScopedAssociation> getBroadestActiveContext() {\r\n        for (Class<? extends ScopedAssociation> scopeType : getAvailableScopedAssociationClasses()) {\r\n            Annotation scopeAnnotation = scopeType.getAnnotations().length > 0 ? scopeType.getAnnotations()[0] : null;\r\n            if (scopeAnnotation == null || !beanManager.isScope(scopeAnnotation.annotationType())) {\r\n                throw new FlowableException(\"ScopedAssociation must carry exactly one annotation and it must be a @Scope annotation\");\r\n            }\r\n            try {\r\n                beanManager.getContext(scopeAnnotation.annotationType());\r\n                return scopeType;\r\n            } catch (ContextNotActiveException e) {\r\n                LOGGER.trace(\"Context {} not active.\", scopeAnnotation.annotationType());\r\n            }\r\n        }\r\n        throw new FlowableException(\"Could not determine an active context to associate the current process instance / task instance with.\");\r\n    }\r\n\r\n    /**\r\n     * Override to add different / additional contexts.\r\n     *\r\n     * @return a list of {@link Scope}-types, which are used in the given order to resolve the broadest active context (@link #getBroadestActiveContext()})\r\n     */\r\n    protected List<Class<? extends ScopedAssociation>> getAvailableScopedAssociationClasses() {\r\n        ArrayList<Class<? extends ScopedAssociation>> scopeTypes = new ArrayList<>();\r","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cdi/src/main/java/org/flowable/cdi/impl/context/DefaultContextAssociationManager.java#L96-L132","documentation":"DefaultContextAssociationManager.getBroadestActiveContext() walks candidate ScopedAssociation classes ordered by context breadth and requires each to carry a CDI @Scope annotation; it uses that annotation to resolve the active CDI context. If a candidate's first annotation is missing or is not a valid scope type according to BeanManager.isScope(), it throws this FlowableException.","triggerScenarios":"One of the ScopedAssociation classes returned by getAvailableScopedAssociationClasses() has no annotations, or its first annotation is not a CDI scope (e.g. custom association class annotated with a plain qualifier instead of @Conversation/@RequestScoped-style scope).","commonSituations":"Subclassing ScopedAssociation to add a custom scope but annotating it incorrectly, or classpath mixing of Flowable CDI versions where association classes changed their annotations, or CDI bean archive misconfiguration altering annotation discovery.","solutions":["Annotate any custom ScopedAssociation subclass with a valid CDI scope, e.g. @ConversationScoped or @RequestScoped.","Ensure the scope annotation's @Scope meta-annotation is present and the CDI bean archive (beans.xml with version/bean-discovery-mode) is set up so annotations are visible.","Align flowable-cdi module version with the rest of your Flowable dependencies."],"exampleFix":"// before\npublic class CustomScopedAssociation extends ScopedAssociation { }\n// after\n@ConversationScoped\npublic class CustomScopedAssociation extends ScopedAssociation { }","handlingStrategy":"validation","validationCode":"Class<?> c = CustomScopedAssociation.class;\nAnnotation a = c.getAnnotations().length > 0 ? c.getAnnotations()[0] : null;\nboolean valid = a != null && a.annotationType().isAnnotationPresent(javax.enterprise.context.Scope.class);\nif (!valid) throw new IllegalStateException(\"ScopedAssociation needs a CDI @Scope annotation\");","typeGuard":"null","tryCatchPattern":"try { businessProcess.getVariable(\"k\"); } catch (FlowableException e) { /* fall back to RuntimeService */ }","preventionTips":["Always annotate custom ScopedAssociation subclasses with a standard CDI scope","Keep beans.xml CDI configuration consistent across all modules","Keep flowable-cdi versions aligned with other Flowable artifacts"],"tags":["cdi","scope-annotation","context-resolution"],"backgroundTag":"invalid-annotation","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}