flowable/flowable-engine · error · ActivitiObjectNotFoundException

execution " + executionId + " doesn't exist

Error message

execution " + executionId + " doesn't exist

What it means

Thrown by HasExecutionVariableCmd.execute() when findExecutionById(executionId) returns null, i.e. no execution exists with the given id. Raised as ActivitiObjectNotFoundException with Execution.class as the referenced class.

Solutions

  1. Verify the execution id exists before the call: runtimeService.createExecutionQuery().executionId(id).singleResult() != null
  2. Handle ActivitiObjectNotFoundException and treat it as 'process already ended'
  3. Fix the source of the stale id (e.g. an async job that outlives its execution)

Example fix

// before
boolean has = runtimeService.hasVariable(executionId, name);
// after
Execution e = runtimeService.createExecutionQuery().executionId(executionId).singleResult();
boolean has = e != null && runtimeService.hasVariable(executionId, name);
Defensive patterns

Strategy: validation

Validate before calling

boolean exists = runtimeService.createExecutionQuery().executionId(executionId).count() > 0;

Try / catch

try { return runtimeService.hasVariable(executionId, name); } catch (ActivitiObjectNotFoundException e) { log.warn("execution {} gone", executionId); return false; }

Prevention

When it happens

Trigger: Calling runtimeService.hasVariable(executionId, name) / hasVariableLocal with an execution id that no longer exists or never existed; the execution ended and was deleted before the check.

Common situations: A process instance finished before the query ran (async continuation or race), a stale execution id persisted in external storage, or a typo/copied id from another engine.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

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

        this.variableName = variableName;
        this.isLocal = isLocal;
    }

    @Override
    public Boolean 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);
        }

        boolean hasVariable = false;

        if (isLocal) {
            hasVariable = execution.hasVariableLocal(variableName);
        } else {
            hasVariable = execution.hasVariable(variableName);
        }

        return hasVariable;
    }
}

View on GitHub (pinned to d6d39ce1c6)