flowable/flowable-engine · error · FlowableObjectNotFoundException
No case instance found for id ${caseInstanceId}
Error message
No case instance found for id ${caseInstanceId} What it means
SetVariablesAsyncCmd verifies that the given caseInstanceId references an existing case instance before adding variables asynchronously. When findById returns null, the id does not match a persisted case instance, so it throws FlowableObjectNotFoundException. This prevents writing variables for a non-existent or already-terminated case.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetVariablesAsyncCmd.java:50
this.variables = variables;
}
@Override
public Void execute(CommandContext commandContext) {
if (caseInstanceId == null) {
throw new FlowableIllegalArgumentException("caseInstanceId is null");
}
if (variables == null) {
throw new FlowableIllegalArgumentException("variables is null");
}
if (variables.isEmpty()) {
throw new FlowableIllegalArgumentException("variables is empty");
}
CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
CaseInstanceEntity caseInstanceEntity = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);
if (caseInstanceEntity == null) {
throw new FlowableObjectNotFoundException("No case instance found for id " + caseInstanceId, CaseInstanceEntity.class);
}
for (String variableName : variables.keySet()) {
addVariable(false, caseInstanceId, null, variableName, variables.get(variableName), caseInstanceEntity.getTenantId(),
cmmnEngineConfiguration.getVariableServiceConfiguration().getVariableService());
}
createSetAsyncVariablesJob(caseInstanceEntity, cmmnEngineConfiguration);
return null;
}
}
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Verify the caseInstanceId via runtimeService.createCaseInstanceQuery().caseInstanceId(id).singleResult() before calling setVariablesAsync.
- Fix the source of the id (log and inspect what value is passed); ensure it is the case instance id, not a plan item or task id.
- Handle completion: if the case has ended, fetch variables from history (historyService) instead of setting runtime variables.
- Wrap the call in try-catch for FlowableObjectNotFoundException and treat it as a business-level 'case no longer active' condition.
Example fix
// before
runtimeService.setVariablesAsync(caseInstanceId, variables);
// after
CaseInstance ci = runtimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();
if (ci != null) {
runtimeService.setVariablesAsync(caseInstanceId, variables);
} else {
LOGGER.warn("Case instance {} no longer active; skipping variable update", caseInstanceId);
} Defensive patterns
Strategy: validation
Validate before calling
boolean exists = cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).count() > 0;
if (!exists) throw new IllegalArgumentException("Unknown caseInstanceId: " + caseInstanceId); Try / catch
try {
runtimeService.setVariablesAsync(caseInstanceId, vars);
} catch (FlowableObjectNotFoundException e) {
// case ended or wrong id; fall back to history-based handling
} Prevention
- Resolve ids from CaseInstance objects, never from hand-typed strings
- Check case state before variable updates in async flows
- Distinguish runtime vs historic case ids in your data model
When it happens
Trigger: Calling CmmnRuntimeService.setVariablesAsync (or the equivalent management API) with a caseInstanceId that does not exist, was mistyped, or whose case instance has already ended and been archived.
Common situations: Using an id from a different process/case engine; storing a stale id after case completion; a race where the case is terminated between lookup and call; passing a plan item or task id instead of the case instance id.
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
- No case instance found for id ${caseInstanceId}
- No case instance found for id ${caseInstanceEntityId}
- Cannot find case instance for id ${caseInstanceId}
- Cannot find case instance with id
- Cannot find case instance with id
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/9b85f1e091c2b689.
Report an issue: GitHub.