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
- Verify with runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult() != null before commenting.
- If the instance has ended, record the note via history APIs or your own audit table instead of addComment.
- Confirm the id is a processInstanceId (not an executionId or definitionId).
- 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
- Only comment on running instances; use history for completed ones.
- Don't confuse executionId/processDefinitionId with processInstanceId.
- Keep runtime-data cleanup jobs aware of pending comment operations.
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
- The process instance with id '{processInstanceId}' could not
- Cannot find processInstance for id '{processInstanceId}'.
- Cannot find task with id {taskId}
- Cannot add a comment to a suspended {execution}
- Cannot find process instance with id
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/68093304f9db7735.
Report an issue: GitHub.