flowable/flowable-engine · error · FlowableObjectNotFoundException

No process instance found for id '${processInstanceId}'

Error message

No process instance found for id '${processInstanceId}'

What it means

Thrown as FlowableObjectNotFoundException when no execution exists for the given processInstanceId. The process instance was either never created, already completed/deleted, or the id is wrong. The exception carries ProcessInstance.class so callers can detect the missing entity type.

Source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/DeleteProcessInstanceCmd.java:49

    private static final long serialVersionUID = 1L;
    protected String processInstanceId;
    protected String deleteReason;

    public DeleteProcessInstanceCmd(String processInstanceId, String deleteReason) {
        this.processInstanceId = processInstanceId;
        this.deleteReason = deleteReason;
    }

    @Override
    public Void execute(CommandContext commandContext) {
        if (processInstanceId == null) {
            throw new FlowableIllegalArgumentException("processInstanceId is null");
        }

        ExecutionEntity processInstanceEntity = CommandContextUtil.getExecutionEntityManager(commandContext).findById(processInstanceId);
        if (processInstanceEntity == null) {
            throw new FlowableObjectNotFoundException("No process instance found for id '" + processInstanceId + "'", ProcessInstance.class);
        }
        if (processInstanceEntity.isDeleted()) {
            return null;
        }

        if (Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, processInstanceEntity.getProcessDefinitionId())) {
            Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();
            compatibilityHandler.deleteProcessInstance(processInstanceId, deleteReason);
        } else {
            CommandContextUtil.getExecutionEntityManager(commandContext).deleteProcessInstance(processInstanceEntity.getProcessInstanceId(), deleteReason, false, true);
        }

        return null;
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Query the instance first with runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult() and skip if null.
  2. Check ACT_RU_EXECUTION (or history tables) to confirm the id ever existed.
  3. Verify you are connected to the same database/engine that owns the instance.
  4. Confirm the id is a process instance id, not an execution/task/plan-item id.
  5. Treat already-completed instances as expected: check HistoricProcessInstanceQuery before deleting.

Example fix

// before
runtimeService.deleteProcessInstance(instanceId, "cancelled");
// after
ProcessInstance pi = runtimeService.createProcessInstanceQuery()
    .processInstanceId(instanceId).singleResult();
if (pi != null) {
    runtimeService.deleteProcessInstance(instanceId, "cancelled");
}
Defensive patterns

Strategy: validation

Validate before calling

ProcessInstance pi = rs.createProcessInstanceQuery().processInstanceId(id).singleResult();
if (pi == null) { /* skip or report */ } else rs.deleteProcessInstance(id, reason);

Try / catch

try { rs.deleteProcessInstance(id, reason); } catch (FlowableObjectNotFoundException e) { log.info("Instance {} already gone", id); }

Prevention

When it happens

Trigger: Calling runtimeService.deleteProcessInstance(id, reason) with an id that findById cannot resolve — nonexistent id, already-terminated instance, id from another engine/database, or a typo.

Common situations: Deleting an instance after a competing request already deleted it; cleaning up stale ids stored in external tables; pointing a test environment client at a production id; using a task id or job id by mistake.

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/776baef8bf7580fc. Report an issue: GitHub.