flowable/flowable-engine · error · FlowableObjectNotFoundException
Cannot find case instance with id
Error message
Cannot find case instance with id
What it means
Thrown by GetIdentityLinksForCaseInstanceCmd when no CaseInstance exists with the given id. The command loads the instance through CaseInstanceEntityManager.findById and throws FlowableObjectNotFoundException when the lookup returns null. The id is a runtime (not historical/deleted) case instance id.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetIdentityLinksForCaseInstanceCmd.java:48
*/
public class GetIdentityLinksForCaseInstanceCmd implements Command<List<IdentityLink>>, Serializable {
private static final long serialVersionUID = 1L;
protected String caseInstanceId;
public GetIdentityLinksForCaseInstanceCmd(String caseInstanceId) {
this.caseInstanceId = caseInstanceId;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public List<IdentityLink> execute(CommandContext commandContext) {
CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
CaseInstance caseInstance = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);
if (caseInstance == null) {
throw new FlowableObjectNotFoundException("Cannot find case instance with id " + caseInstanceId, CaseInstanceEntity.class);
}
return (List) cmmnEngineConfiguration.getIdentityLinkServiceConfiguration().getIdentityLinkService()
.findIdentityLinksByScopeIdAndType(caseInstanceId, ScopeTypes.CMMN);
}
}
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Confirm the case instance is still running: check cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(id).count() > 0.
- If the case has ended, query history instead (cmmnHistoryService) for identity links if available.
- Make sure both start and query use the same engine/database; add tenant checks if multi-tenant.
- Log and validate the id at the call site; do not pass business keys as instance ids.
Example fix
// before
List<IdentityLink> links = cmmnRuntimeService.getIdentityLinksForCaseInstance(caseId);
// after
if (cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseId).count() == 0) {
throw new IllegalStateException("Case instance not found: " + caseId);
}
List<IdentityLink> links = cmmnRuntimeService.getIdentityLinksForCaseInstance(caseId); Defensive patterns
Strategy: validation
Validate before calling
if (cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).count() == 0) {
throw new IllegalArgumentException("Unknown case instance id: " + caseInstanceId);
} Type guard
boolean caseInstanceRunning(String id) {
return cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(id).count() > 0;
} Try / catch
try {
links = cmmnRuntimeService.getIdentityLinksForCaseInstance(caseInstanceId);
} catch (FlowableObjectNotFoundException e) {
log.warn("Case instance {} not found (completed or wrong db)", caseInstanceId);
links = Collections.emptyList();
} Prevention
- Check the case instance query before identity-link calls
- Use history services for ended cases
- Never confuse business key with instance id
- Pin all services to one engine/database
When it happens
Trigger: Calling cmmnRuntimeService.getIdentityLinksForCaseInstance(caseInstanceId) with an id of an already-completed case, a case started in another engine/database, or a mistyped/never-created id.
Common situations: Querying identity links for cases that ended and were removed (or only exist in history tables); environment mismatch between where the case was started and where it is queried; id confusion between case instance id and business key.
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 case instance for id ${caseInstanceId}
- Cannot find case instance with id
- case instance ${caseInstanceId} doesn't exist
- No case instance found for id = '${caseInstanceId}'.
- No case instance found for id = '${caseInstanceId}'.
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/3b08e4ee6a037218.
Report an issue: GitHub.