flowable/flowable-engine · error · ActivitiObjectNotFoundException
No process instance found for id
Error message
No process instance found for id '<processInstanceId>'
What it means
deleteProcessInstance looks up the execution row for the given process instance id before cascading the delete. If no execution entity exists with that id, the engine throws ActivitiObjectNotFoundException. It signals the target process instance does not exist (or was already deleted / never started in this engine's database).
Solutions
- Verify the processInstanceId via runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult() before deleting.
- Check you are connected to the correct database/schema and tenant the instance lives in.
- If the instance may have already ended, look it up in history (historicProcessInstanceQuery) and skip deletion or delete history instead.
- Handle ActivitiObjectNotFoundException as a benign already-deleted case in idempotent cleanup code.
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 = runtimeService.createProcessInstanceQuery()
.processInstanceId(instanceId).singleResult();
if (pi == null) { /* skip or delete history instead */ } Try / catch
try {
runtimeService.deleteProcessInstance(instanceId, reason);
} catch (ActivitiObjectNotFoundException e) {
log.info("Instance {} already gone; treating as deleted", instanceId);
} Prevention
- Check existence with a processInstanceQuery before deleting
- Make cleanup jobs idempotent by ignoring not-found exceptions
- Confirm database/tenant before operating on ids from other environments
When it happens
Trigger: Calling RuntimeService.deleteProcessInstance(processInstanceId, reason) with an id that has no execution row; the instance already completed or was deleted; the id belongs to a different database/tenant; a historic-only id is passed.
Common situations: Race conditions where a job or another thread completes the instance between lookup and delete; pointing at a test database while the instance lives in production; using a process instance id from an export/backup of another environment; deleting in a retry loop without checking existence.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Cannot find process instance with id
- Cannot find process instance with id
- No process instance found for id =
- No process instance found for id =
- No process instance found for id =
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/335dc3553d01de39.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/persistence/entity/ExecutionEntityManager.java:67
}
if (cascade) {
Context
.getCommandContext()
.getHistoricProcessInstanceEntityManager()
.deleteHistoricProcessInstanceByProcessDefinitionId(processDefinitionId);
}
}
public void deleteProcessInstance(String processInstanceId, String deleteReason) {
deleteProcessInstance(processInstanceId, deleteReason, false);
}
public void deleteProcessInstance(String processInstanceId, String deleteReason, boolean cascade) {
ExecutionEntity execution = findExecutionById(processInstanceId);
if (execution == null) {
throw new ActivitiObjectNotFoundException("No process instance found for id '" + processInstanceId + "'", ProcessInstance.class);
}
deleteProcessInstanceCascade(execution, deleteReason, cascade);
}
private void deleteProcessInstanceCascade(ExecutionEntity execution, String deleteReason, boolean deleteHistory) {
CommandContext commandContext = Context.getCommandContext();
ProcessInstanceQueryImpl processInstanceQuery = new ProcessInstanceQueryImpl(commandContext);
List<ProcessInstance> subProcesses = processInstanceQuery.superProcessInstanceId(execution.getProcessInstanceId()).list();
for (ProcessInstance subProcess : subProcesses) {
deleteProcessInstanceCascade((ExecutionEntity) subProcess, deleteReason, deleteHistory);
}
commandContext
.getTaskEntityManager()
.deleteTasksByProcessInstanceId(execution.getId(), deleteReason, deleteHistory);
View on GitHub (pinned to d6d39ce1c6)