flowable/flowable-engine · error · FlowableObjectNotFoundException
Cannot find case instance for id ${caseInstanceId}
Error message
Cannot find case instance for id ${caseInstanceId} What it means
FlowableableObjectNotFoundException thrown in AbstractNeedsCaseInstanceCmd.execute after findById on the CaseInstanceEntityManager returns null. The engine verified the id was non-null but no CaseInstanceEntity with that id exists in the runtime tables. Commands like changing case state or submitting a form refuse to proceed without a live case instance.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AbstractNeedsCaseInstanceCmd.java:45
*/
public abstract class AbstractNeedsCaseInstanceCmd implements Command<Void>, Serializable {
protected String caseInstanceId;
public AbstractNeedsCaseInstanceCmd(String caseInstanceId) {
this.caseInstanceId = caseInstanceId;
}
@Override
public Void execute(CommandContext commandContext) {
if (caseInstanceId == null) {
throw new FlowableIllegalArgumentException("Case instance id is null");
}
CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
CaseInstanceEntity caseInstanceEntity = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);
if (caseInstanceEntity == null) {
throw new FlowableObjectNotFoundException("Cannot find case instance for id " + caseInstanceId, CaseInstanceEntity.class);
}
internalExecute(commandContext, caseInstanceEntity);
return null;
}
protected abstract void internalExecute(CommandContext commandContext, CaseInstanceEntity caseInstanceEntity);
}
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Verify the case instance is still active via cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(id).singleResult() before the command
- Use the historical service (cmmnHistoryService) if you only need data for a completed case
- Confirm the id against the ACT_CMMN_RU_CASE_INST table / Flowable admin UI
- Check you are pointed at the same database and tenant the case was created in
Example fix
// before
cmmnTaskService.completePlanItemStandaloneForm(planItemInstanceId, caseInstanceId, formInfo, variables);
// after
CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();
if (caseInstance == null) {
throw new IllegalArgumentException("No active case instance for id " + caseInstanceId);
}
cmmnTaskService.completePlanItemStandaloneForm(planItemInstanceId, caseInstanceId, formInfo, variables); Defensive patterns
Strategy: validation
Validate before calling
CaseInstance ci = cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();
if (ci == null) throw new IllegalStateException("Case instance " + caseInstanceId + " not found or already ended"); Try / catch
try { cmmnTaskService.completePlanItemStandaloneForm(...); }
catch (FlowableObjectNotFoundException e) { log.info("Case instance gone: {}", e.getMessage()); } Prevention
- Check case existence/state before case-scoped commands
- Remember runtime rows vanish on completion — use history for ended cases
- Never assume ids are valid across engines/databases/tenants
- Clean up stale ids in queues when cases terminate
When it happens
Trigger: Calling case-level commands with a caseInstanceId that was deleted or never created; using the historic instance id after the case completed (runtime row removed); id from a different engine/database.
Common situations: Id stored/passed around after the case instance ended (runtime rows are removed on completion); typo or truncated id; multi-tenant setup querying the wrong tenant's engine; test using random ids without creating an instance.
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 with id
- 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/cc86c531f7a8a56c.
Report an issue: GitHub.