flowable/flowable-engine · error · FlowableObjectNotFoundException

execution {processInstanceId} doesn't exist

Error message

execution {processInstanceId} doesn't exist

What it means

FlowableObjectNotFoundException thrown by AddCommentCmd.execute when a processInstanceId was supplied but no execution with that id exists. The comment is anchored to the process instance, so the command validates its execution before writing.

Source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/AddCommentCmd.java:78

        // Validate task
        if (taskId != null) {
            task = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);

            if (task == null) {
                throw new FlowableObjectNotFoundException("Cannot find task with id " + taskId, Task.class);
            }

            if (task.isSuspended()) {
                throw new FlowableException("Cannot add a comment to a suspended " + task);
            }
        }

        ExecutionEntity execution = null;
        if (processInstanceId != null) {
            execution = processEngineConfiguration.getExecutionEntityManager().findById(processInstanceId);

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

            if (execution.isSuspended()) {
                throw new FlowableException("Cannot add a comment to a suspended " + execution);
            }
        }

        String processDefinitionId = null;
        if (execution != null) {
            processDefinitionId = execution.getProcessDefinitionId();
        } else if (task != null) {
            processDefinitionId = task.getProcessDefinitionId();
        }

        if (Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, processDefinitionId)) {
            Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();
            return compatibilityHandler.addComment(taskId, processInstanceId, type, message);
        }

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Verify with runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult() != null before commenting.
  2. If the instance has ended, record the note via history APIs or your own audit table instead of addComment.
  3. Confirm the id is a processInstanceId (not an executionId or definitionId).
  4. Ensure the comment and process operations run against the same engine/database.

Example fix

// before
taskService.addComment(null, processInstanceId, msg);
// after
ProcessInstance pi = runtimeService.createProcessInstanceQuery()
    .processInstanceId(processInstanceId).singleResult();
if (pi != null) {
    taskService.addComment(null, processInstanceId, msg);
}
Defensive patterns

Strategy: validation

Validate before calling

if (runtimeService.createProcessInstanceQuery()
        .processInstanceId(processInstanceId).singleResult() == null) {
    throw new IllegalArgumentException("Unknown process instance: " + processInstanceId);
}

Try / catch

try {
    taskService.addComment(null, processInstanceId, msg);
} catch (FlowableObjectNotFoundException e) {
    // instance ended or unknown; record via history/audit store
}

Prevention

When it happens

Trigger: taskService.addComment(null, processInstanceId, message) with an unknown, ended, or removed process instance id.

Common situations: Commenting on a process instance after it completed and runtime data was cleaned; wrong-schema/wrong-engine deployments; passing processDefinitionId or executionId instead of the process instance id.

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