flowable/flowable-engine · error · ActivitiObjectNotFoundException
Cannot find process instance with id
Error message
Cannot find process instance with id ${processInstanceId} What it means
The command looked up processInstanceId via the execution entity manager and found no execution with that id, so it throws ActivitiObjectNotFoundException with ExecutionEntity as the missing-object class. Identity links exist only on live runtime executions; a stale or invalid id cannot be targeted.
Solutions
- Verify the instance exists and is running first: runtimeService.createProcessInstanceQuery().processInstanceId(pid).singleResult() != null.
- If the instance is finished, operate on history or skip deletion — runtime links are gone with the execution.
- Confirm the id is a process instance/execution id, not a task or job id.
- Check you are connected to the engine/database that owns the id (correct datasource and engine version).
Example fix
// before
runtimeService.deleteProcessInstanceIdentityLink(pid, userId, groupId, type);
// after
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(pid).singleResult();
if (pi != null) {
runtimeService.deleteProcessInstanceIdentityLink(pid, userId, groupId, type);
} Defensive patterns
Strategy: try-catch
Validate before calling
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(pid).singleResult();
if (pi == null) {
return; // instance already ended or id invalid; nothing to unlink
} Type guard
boolean isRunningProcessInstance(RuntimeService rs, String pid) {
return pid != null && rs.createProcessInstanceQuery().processInstanceId(pid).count() > 0;
} Try / catch
try {
runtimeService.deleteProcessInstanceIdentityLink(pid, userId, groupId, type);
} catch (ActivitiObjectNotFoundException e) {
if (ExecutionEntity.class.equals(e.getObjectClass())) {
LOGGER.warn("Process instance {} no longer exists; skipping identity link cleanup", pid);
return;
}
throw e;
} Prevention
- Check existence with a ProcessInstanceQuery before mutating runtime links.
- Treat completed/aborted instances as no-op for link cleanup in maintenance jobs.
- Verify ids refer to the same engine instance and datasource.
- Do not confuse taskId with processInstanceId.
When it happens
Trigger: Calling deleteProcessInstanceIdentityLink with a processInstanceId that matches no execution: instance already completed or aborted (history-only), wrong id type (taskId/jobId), or an id from a different engine/database.
Common situations: Cleanup jobs deleting links after the process already ended; subprocess vs. process-instance id mismatches; multi-engine/multi-tenant setups where the id belongs to another engine's datasource.
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
- The process instance with id
- Cannot find process definition with id
- Cannot find process definition with id
- Cannot find process definition with id
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/9589bd9acc315de8.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteIdentityLinkForProcessInstanceCmd.java:66
if (processInstanceId == null) {
throw new ActivitiIllegalArgumentException("processInstanceId is null");
}
if (type == null) {
throw new ActivitiIllegalArgumentException("type is required when deleting a process identity link");
}
if (userId == null && groupId == null) {
throw new ActivitiIllegalArgumentException("userId and groupId cannot both be null");
}
}
@Override
public Void execute(CommandContext commandContext) {
ExecutionEntity processInstance = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);
if (processInstance == null) {
throw new ActivitiObjectNotFoundException("Cannot find process instance with id " + processInstanceId, ExecutionEntity.class);
}
processInstance.deleteIdentityLink(userId, groupId, type);
commandContext.getHistoryManager().createProcessInstanceIdentityLinkComment(processInstanceId, userId, groupId, type, false);
return null;
}
}
View on GitHub (pinned to d6d39ce1c6)