flowable/flowable-engine · error · ActivitiObjectNotFoundException

process instance <processInstanceId> doesn't exist

Error message

process instance <processInstanceId> doesn't exist

What it means

SetProcessInstanceNameCmd throws ActivitiObjectNotFoundException when no execution entity exists for the supplied processInstanceId. The engine looks up the execution by ID and, finding nothing, cannot set a name on a non-existent process instance, so it aborts before any mutation. ProcessInstance.class is passed as the missing-object type so callers can identify what was not found.

Source

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

    protected String name;

    public SetProcessInstanceNameCmd(String processInstanceId, String name) {
        this.processInstanceId = processInstanceId;
        this.name = name;
    }

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

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

        if (execution == null) {
            throw new ActivitiObjectNotFoundException("process instance " + processInstanceId + " doesn't exist", ProcessInstance.class);
        }

        if (!execution.isProcessInstanceType()) {
            throw new ActivitiObjectNotFoundException("process instance " + processInstanceId +
                    " doesn't exist, the given ID references an execution, though", ProcessInstance.class);
        }

        if (execution.isSuspended()) {
            throw new ActivitiException("process instance " + processInstanceId + " is suspended, cannot set name");
        }

        // Actually set the name
        execution.setName(name);

        // Record the change in history
        commandContext.getHistoryManager().recordProcessInstanceNameChange(processInstanceId, name);

        return null;

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Verify the processInstanceId exists before calling: runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult() != null.
  2. Check whether the instance already ended; if it finished, the name can no longer be changed (set it at start time via ProcessInstanceBuilder.processInstanceName(name)).
  3. Log and correct the source of the ID — it may come from a stale cache or a history record after cleanup.

Example fix

// before
runtimeService.setProcessInstanceName(processInstanceId, "monthly-run");
// after
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
if (pi != null) {
    runtimeService.setProcessInstanceName(processInstanceId, "monthly-run");
}
Defensive patterns

Strategy: validation

Validate before calling

boolean exists = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).count() > 0;
if (!exists) throw new IllegalArgumentException("Unknown process instance: " + processInstanceId);

Try / catch

try {
    runtimeService.setProcessInstanceName(processInstanceId, name);
} catch (ActivitiObjectNotFoundException e) {
    logger.warn("Process instance {} not found; skipping rename", processInstanceId, e);
}

Prevention

When it happens

Trigger: Calling RuntimeService.setProcessInstanceName(processInstanceId, name) with an ID that does not match any row in ACT_RU_EXECUTION, e.g. after the process instance completed or was deleted.

Common situations: Stale IDs held by a client after the instance finished; ID taken from history tables (ACT_HI_PROCINST) after cleanup; typo'd or truncated instance ID; instance removed by a concurrent job or deleteProcessInstance call.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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