flowable/flowable-engine · error · ActivitiIllegalArgumentException

executionId is null

Error message

executionId is null

What it means

GetExecutionVariableCmd.execute validates executionId and throws ActivitiIllegalArgumentException when it is null. Variables are fetched from a specific execution, so a null execution id is invalid before any database lookup happens.

Solutions

  1. Obtain the execution id from runtimeService.createExecutionQuery().processInstanceId(pid).singleResult().getId() or from a Task's executionId.
  2. Guard the executionId for null before calling getVariable.
  3. If the process may have ended, check processInstance existence first and read historical variables via HistoryService instead.

Example fix

// before
Object value = runtimeService.getVariable(executionId, "orderId");
// after
if (executionId == null) {
    executionId = taskService.createTaskQuery().taskId(taskId).singleResult().getExecutionId();
}
Object value = runtimeService.getVariable(executionId, "orderId");
Defensive patterns

Strategy: validation

Validate before calling

if (executionId == null) {
    throw new IllegalStateException("executionId is required to read variables");
}

Type guard

boolean isRunningExecution(ExecutionEntity e) { return e != null && e.getId() != null; }

Try / catch

try {
    return runtimeService.getVariable(executionId, variableName);
} catch (ActivitiIllegalArgumentException e) {
    throw new IllegalStateException("executionId/variableName must be non-null", e);
}

Prevention

When it happens

Trigger: runtimeService.getVariable(executionId, variableName) / getVariableLocal(...) with a null executionId.

Common situations: ExecutionEntity reference was null and its getId() propagated null; process ended before the variable read so no execution id was captured; task-to-execution resolution returned nothing.

Related errors


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

Appendix: source

Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetExecutionVariableCmd.java:44

 * @author Joram Barrez
 */
public class GetExecutionVariableCmd implements Command<Object>, Serializable {

    private static final long serialVersionUID = 1L;
    protected String executionId;
    protected String variableName;
    protected boolean isLocal;

    public GetExecutionVariableCmd(String executionId, String variableName, boolean isLocal) {
        this.executionId = executionId;
        this.variableName = variableName;
        this.isLocal = isLocal;
    }

    @Override
    public Object execute(CommandContext commandContext) {
        if (executionId == null) {
            throw new ActivitiIllegalArgumentException("executionId is null");
        }
        if (variableName == null) {
            throw new ActivitiIllegalArgumentException("variableName is null");
        }

        ExecutionEntity execution = commandContext
                .getExecutionEntityManager()
                .findExecutionById(executionId);

        if (execution == null) {
            throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
        }

        Object value;

        if (isLocal) {
            value = execution.getVariableLocal(variableName, false);
        } else {

View on GitHub (pinned to d6d39ce1c6)