flowable/flowable-engine · error · UnsupportedOperationException

No execution active, no variables can be set

Error message

No execution active, no variables can be set

What it means

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.

Solutions

  1. Use a real execution-backed scope (DelegateExecution, TaskEntity, ExecutionEntity) instead of NoExecutionVariableScope for writes
  2. Restrict the code path to read-only operations when no execution is active
  3. Construct a VariableScopeImpl or a mock scope in tests when you need setVariable support
  4. Check instanceof NoExecutionVariableScope before attempting variable writes

Example fix

// before
VariableScope scope = new NoExecutionVariableScope();
scope.setVariable("count", 3); // throws
// after
ExecutionEntity execution = runtimeService.createExecutionQuery().executionId(id).singleResult();
runtimeService.setVariable(execution.getId(), "count", 3);
Defensive patterns

Strategy: try-catch

Validate before calling

if (scope instanceof NoExecutionVariableScope) {
    throw new IllegalStateException("Cannot set variables without an execution");
}

Type guard

boolean canWriteVariables(VariableScope scope) {
    return !(scope instanceof NoExecutionVariableScope);
}

Try / catch

try {
    scope.setVariable("k", v);
} catch (UnsupportedOperationException e) {
    if (e.getMessage().contains("No execution active")) {
        // fall back to service API with explicit executionId
    } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/8425929eb1e32acd. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/el/NoExecutionVariableScope.java:171

    @Override
    public VariableInstance getVariableInstanceLocal(String variableName, boolean fetchAllVariables) {
        return null;
    }

    @SuppressWarnings("unchecked")
    @Override
    public Set<String> getVariableNames() {
        return Collections.EMPTY_SET;
    }

    @Override
    public Set<String> getVariableNamesLocal() {
        return null;
    }

    @Override
    public void setVariable(String variableName, Object value) {
        throw new UnsupportedOperationException("No execution active, no variables can be set");
    }

    @Override
    public void setVariable(String variableName, Object value, boolean fetchAllVariables) {
        throw new UnsupportedOperationException("No execution active, no variables can be set");
    }

    @Override
    public Object setVariableLocal(String variableName, Object value) {
        throw new UnsupportedOperationException("No execution active, no variables can be set");
    }

    @Override
    public Object setVariableLocal(String variableName, Object value, boolean fetchAllVariables) {
        throw new UnsupportedOperationException("No execution active, no variables can be set");
    }
    
    @Override

View on GitHub (pinned to d6d39ce1c6)