flowable/flowable-engine · error · FlowableObjectNotFoundException
Cannot find process instance with id
Error message
Cannot find process instance with id
What it means
GetIdentityLinksForProcessInstanceCmd.execute fetches the process instance (ExecutionEntity) by id and throws FlowableObjectNotFoundException if findById returns null. Identity links on a process instance are stored with the execution, so a missing execution means no links can be returned. Throwing here prevents a NullPointerException on processInstance.getIdentityLinks().
Solutions
- If the instance may have completed, use historyService.createHistoricProcessInstanceQuery().processInstanceId(id) to confirm it ended
- Fetch identity links from history APIs for finished instances instead of RuntimeService
- Validate the id is an active runtime instance: runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult()
- Check you are on the correct database/environment for the id
- Catch FlowableObjectNotFoundException and treat the instance as gone
Example fix
// before
List<IdentityLink> links = runtimeService.getIdentityLinksForProcessInstance(pid);
// after
if (runtimeService.createProcessInstanceQuery().processInstanceId(pid).count() == 0) {
throw new IllegalStateException("Process instance not active: " + pid);
}
List<IdentityLink> links = runtimeService.getIdentityLinksForProcessInstance(pid); Defensive patterns
Strategy: try-catch
Validate before calling
boolean active = runtimeService.createProcessInstanceQuery().processInstanceId(pid).count() > 0;
Try / catch
try {
List<IdentityLink> links = runtimeService.getIdentityLinksForProcessInstance(pid);
} catch (FlowableObjectNotFoundException e) {
// instance ended or never existed; fall back to history queries
links = Collections.emptyList();
} Prevention
- Only query runtime identity links for instances still in ACT_RU_EXECUTION
- For finished instances use the history service instead
- Avoid caching process instance ids across long-lived UI sessions
- Verify datasource/environment consistency
When it happens
Trigger: Calling RuntimeService.getIdentityLinksForProcessInstance(processInstanceId) with an id for an instance that already ended (and was removed from runtime tables), was deleted, or never existed in the connected database.
Common situations: Looking up links for a completed process instance (moved to history, gone from ACT_RU_EXECUTION); id captured before an async completion/cleanup job ran; cross-environment id reuse; passing a historic process instance id into the runtime API.
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
- Cannot find process definition with id
- Cannot find process instance with id
- Cannot find process instance with id
- Cannot find process instance with id
- Cannot find process instance with id
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/54e55a00b10b0a21.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetIdentityLinksForProcessInstanceCmd.java:44
* @author Marcus Klimstra
*/
public class GetIdentityLinksForProcessInstanceCmd implements Command<List<IdentityLink>>, Serializable {
private static final long serialVersionUID = 1L;
protected String processInstanceId;
public GetIdentityLinksForProcessInstanceCmd(String processInstanceId) {
this.processInstanceId = processInstanceId;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public List<IdentityLink> execute(CommandContext commandContext) {
ExecutionEntity processInstance = CommandContextUtil.getExecutionEntityManager(commandContext).findById(processInstanceId);
if (processInstance == null) {
throw new FlowableObjectNotFoundException("Cannot find process instance with id " + processInstanceId, ExecutionEntity.class);
}
return (List) processInstance.getIdentityLinks();
}
}
View on GitHub (pinned to d6d39ce1c6)