{"record":{"id":"47f3cbd5534dc1af","repo":"flowable/flowable-engine","slug":"no-execution-active-no-variables-can-be-set-47f3cb","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/flowable5-engine/src/main/java/org/activiti/engine/impl/el/NoExecutionVariableScope.java","lineNumber":170,"sourceCode":"\n    @Override\n    public VariableInstance getVariableInstance(String variableName, boolean fetchAllVariables) {\n        return null;\n    }\n\n    @Override\n    public VariableInstance getVariableInstanceLocal(String variableName) {\n        return null;\n    }\n\n    @Override\n    public VariableInstance getVariableInstanceLocal(String variableName, boolean fetchAllVariables) {\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":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/el/NoExecutionVariableScope.java#L152-L188","documentation":"NoExecutionVariableScope is a placeholder VariableScope used when no execution exists (e.g. evaluating expressions outside a running execution). All mutating variable operations are intentionally unsupported and throw UnsupportedOperationException.","triggerScenarios":"Calling setVariable(String, Object) on a NoExecutionVariableScope instance.","commonSituations":"Expressions or delegates evaluated without an active execution (e.g. task listeners on transient contexts, expression evaluation in unit tests without an execution); passing the wrong VariableScope into a helper that tries to persist a variable.","solutions":["Obtain the real ExecutionEntity/DelegateExecution and set the variable on it instead","Restructure logic so variable writes only happen inside an active execution (e.g. execution listeners, service tasks)","Guard code with hasExecution checks before attempting writes when scope may be NoExecutionVariableScope","Use a TaskEntity's scope (which has a backing execution) rather than a bare NoExecutionVariableScope"],"exampleFix":"// before\nnoExecutionScope.setVariable(\"status\", \"done\");\n// after\nif (execution != null) { execution.setVariable(\"status\", \"done\"); }","handlingStrategy":"type-guard","validationCode":"if (scope instanceof NoExecutionVariableScope) {\n  throw new IllegalStateException(\"Cannot set variables: no execution active\");\n}","typeGuard":"boolean canSetVariables(VariableScope scope) {\n  return !(scope instanceof NoExecutionVariableScope);\n}","tryCatchPattern":"try {\n  scope.setVariable(name, value);\n} catch (UnsupportedOperationException e) {\n  // no execution active: defer or log\n  logger.warn(\"Variable {} not set: {}\", name, e.getMessage());\n}","preventionTips":["Only write variables inside execution-bound code (delegates, listeners, tasks)","Never treat NoExecutionVariableScope as a writable container","In unit tests, mock a DelegateExecution for variable operations"],"tags":["variables","execution","flowable","unsupported-operation"],"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"}