{"record":{"id":"8425929eb1e32acd","repo":"flowable/flowable-engine","slug":"no-execution-active-no-variables-can-be-set","errorCode":null,"errorMessage":"No execution active, no variables can be set","messagePattern":"No execution active, no variables can be set","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/el/NoExecutionVariableScope.java","lineNumber":171,"sourceCode":"    @Override\n    public VariableInstance getVariableInstanceLocal(String variableName, boolean fetchAllVariables) {\n        return null;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public Set<String> getVariableNames() {\n        return Collections.EMPTY_SET;\n    }\n\n    @Override\n    public Set<String> getVariableNamesLocal() {\n        return null;\n    }\n\n    @Override\n    public void setVariable(String variableName, Object value) {\n        throw new UnsupportedOperationException(\"No execution active, no variables can be set\");\n    }\n\n    @Override\n    public void setVariable(String variableName, Object value, boolean fetchAllVariables) {\n        throw new UnsupportedOperationException(\"No execution active, no variables can be set\");\n    }\n\n    @Override\n    public Object setVariableLocal(String variableName, Object value) {\n        throw new UnsupportedOperationException(\"No execution active, no variables can be set\");\n    }\n\n    @Override\n    public Object setVariableLocal(String variableName, Object value, boolean fetchAllVariables) {\n        throw new UnsupportedOperationException(\"No execution active, no variables can be set\");\n    }\n    \n    @Override","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/el/NoExecutionVariableScope.java#L153-L189","documentation":"NoExecutionVariableScope is a VariableScope stub used by the EL/ expression layer when evaluation happens outside any execution (e.g. in a standalone expression evaluation). All mutating operations are intentionally unsupported: calling setVariable(name, value) on it always throws UnsupportedOperationException. It signals that variable writes require an active execution/execution context.","triggerScenarios":"Calling setVariable(String, Object) on a VariableScope reference that actually is NoExecutionVariableScope, typically an expression or delegate getting a scope that is not backed by an ExecutionEntity/TaskEntity.","commonSituations":"Evaluating expressions with a manually constructed VariableScope; unit-test code reusing NoExecutionVariableScope as a dummy; Spring/CDN beans or JUEL expressions resolving variables outside a process context (e.g. in a listener without an execution).","solutions":["Use a real execution-backed scope (DelegateExecution, TaskEntity, ExecutionEntity) instead of NoExecutionVariableScope for writes","Restrict the code path to read-only operations when no execution is active","Construct a VariableScopeImpl or a mock scope in tests when you need setVariable support","Check instanceof NoExecutionVariableScope before attempting variable writes"],"exampleFix":"// before\nVariableScope scope = new NoExecutionVariableScope();\nscope.setVariable(\"count\", 3); // throws\n// after\nExecutionEntity execution = runtimeService.createExecutionQuery().executionId(id).singleResult();\nruntimeService.setVariable(execution.getId(), \"count\", 3);","handlingStrategy":"try-catch","validationCode":"if (scope instanceof NoExecutionVariableScope) {\n    throw new IllegalStateException(\"Cannot set variables without an execution\");\n}","typeGuard":"boolean canWriteVariables(VariableScope scope) {\n    return !(scope instanceof NoExecutionVariableScope);\n}","tryCatchPattern":"try {\n    scope.setVariable(\"k\", v);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().contains(\"No execution active\")) {\n        // fall back to service API with explicit executionId\n    } else throw e;\n}","preventionTips":["Never use NoExecutionVariableScope in code paths that write variables","Pass DelegateExecution/DelegateTask from delegates rather than a stub scope","Keep expression evaluation that needs writes inside process execution contexts","In tests, use a mock VariableScope with write support instead of the stub"],"tags":["variables","unsupported-operation","flowable"],"backgroundTag":"unsupported-operation","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"}