flowable/flowable-engine · error · ActivitiObjectNotFoundException

Cannot find processInstance for id '${executionId}'.

Error message

Cannot find processInstance for id '${executionId}'.

What it means

AbstractSetProcessInstanceStateCmd.execute looks up the execution by id via the execution entity manager and throws ActivitiObjectNotFoundException when no execution with that id exists. The suspension state of a non-existent process instance cannot be changed.

Source

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

public abstract class AbstractSetProcessInstanceStateCmd implements Command<Void> {

    protected final String executionId;

    public AbstractSetProcessInstanceStateCmd(String executionId) {
        this.executionId = executionId;
    }

    @Override
    public Void execute(CommandContext commandContext) {

        if (executionId == null) {
            throw new ActivitiIllegalArgumentException("ProcessInstanceId cannot be null.");
        }

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

        if (executionEntity == null) {
            throw new ActivitiObjectNotFoundException("Cannot find processInstance for id '" + executionId + "'.", Execution.class);
        }
        if (!executionEntity.isProcessInstanceType()) {
            throw new ActivitiException("Cannot set suspension state for execution '" + executionId + "': not a process instance.");
        }

        SuspensionStateUtil.setSuspensionState(executionEntity, getNewState());

        // All child executions are suspended
        List<ExecutionEntity> childExecutions = commandContext.getExecutionEntityManager().findChildExecutionsByProcessInstanceId(executionId);
        for (ExecutionEntity childExecution : childExecutions) {
            if (!childExecution.getId().equals(executionId)) {
                SuspensionStateUtil.setSuspensionState(childExecution, getNewState());
            }
        }

        // All tasks are suspended
        List<TaskEntity> tasks = commandContext.getTaskEntityManager().findTasksByProcessInstanceId(executionId);
        for (TaskEntity taskEntity : tasks) {

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Confirm the id exists: runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult() != null before suspending/activating.
  2. Use the id returned by ProcessInstance.getId() from the API, not the business key.
  3. Re-check which database/environment the engine connects to; stale ids from another environment throw here.
  4. If the instance may have finished, handle the not-found case gracefully instead of failing.

Example fix

// before
runtimeService.activateProcessInstanceById(procId);
// after
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(procId).singleResult();
if (pi != null) { runtimeService.activateProcessInstanceById(procId); }
Defensive patterns

Strategy: validation

Validate before calling

ProcessInstance pi = runtimeService.createProcessInstanceQuery()
    .processInstanceId(id).singleResult();
if (pi == null) { throw new IllegalStateException("No running process instance " + id); }

Try / catch

try {
    runtimeService.activateProcessInstanceById(id);
} catch (ActivitiObjectNotFoundException e) {
    if (e.getMessage().startsWith("Cannot find processInstance for id")) {
        logger.warn("Instance {} no longer running", id);
    } else { throw e; }
}

Prevention

When it happens

Trigger: Calling RuntimeService.suspendProcessInstanceById(id)/activateProcessInstanceById(id) with an id that does not exist, was mistyped, or belongs to a process instance that already ended and was removed.

Common situations: Using a stale id from a previous run or another database/environment; confusing business key with instance id; the instance completed and was cleaned up before the suspend call.

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