flowable/flowable-engine · error · FlowableObjectNotFoundException
No plan item instance found for id
Error message
No plan item instance found for id
What it means
Flowable's RemoveLocalVariablesCmd removes local variables from a CMMN plan item instance. Before doing so it looks up the plan item instance by the given id; if no such entity exists in the database, it throws FlowableObjectNotFoundException so the caller knows the id does not reference an existing plan item instance.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/RemoveLocalVariablesCmd.java:48
protected Collection<String> variableNames;
public RemoveLocalVariablesCmd(String planItemInstanceId, Collection<String> variableNames) {
this.planItemInstanceId = planItemInstanceId;
this.variableNames = variableNames;
}
@Override
public Void execute(CommandContext commandContext) {
if (planItemInstanceId == null) {
throw new FlowableIllegalArgumentException("planItemInstanceId is null");
}
if (variableNames == null) {
throw new FlowableIllegalArgumentException("variableNames is null");
}
PlanItemInstanceEntity planItemInstanceEntity = CommandContextUtil.getPlanItemInstanceEntityManager(commandContext).findById(planItemInstanceId);
if (planItemInstanceEntity == null) {
throw new FlowableObjectNotFoundException("No plan item instance found for id " + planItemInstanceId, PlanItemInstanceEntity.class);
}
planItemInstanceEntity.removeVariables(variableNames);
return null;
}
}
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Verify the plan item instance id exists before calling: PlanItemInstanceQuery q = cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(id); singleResult() != null
- Use the correct id type — plan item instance ids come from PlanItemInstance.getId(), not CaseInstance.getId() or Task.getId()
- Check you are connected to the same database/schema the case was created in
- If the plan item may legitimately be gone, catch FlowableObjectNotFoundException and handle gracefully
Example fix
// before
cmmnRuntimeService.removeLocalVariables(planItemInstanceId, names);
// after
if (cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(planItemInstanceId).count() > 0) {
cmmnRuntimeService.removeLocalVariables(planItemInstanceId, names);
} else {
logger.warn("Plan item instance {} not found, skipping variable removal", planItemInstanceId);
} Defensive patterns
Strategy: validation
Validate before calling
boolean exists = cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(planItemInstanceId).count() > 0;
if (!exists) throw new IllegalArgumentException("Unknown planItemInstanceId: " + planItemInstanceId); Try / catch
try { cmmnRuntimeService.removeLocalVariables(id, names); } catch (FlowableObjectNotFoundException e) { log.warn("Plan item instance {} not found", id); } Prevention
- Always resolve plan item ids from a fresh PlanItemInstance query
- Never reuse ids across case completions or database resets
- Distinguish plan item instance ids from case/task ids
When it happens
Trigger: Calling RuntimeService/TaskService local variable removal (e.g. removeLocalVariables(planItemInstanceId, names)) with a planItemInstanceId that does not exist, was already deleted (case/completed plan item purged), or belongs to another engine database.
Common situations: Stale ids cached in application code after case instance completion; using a case instance id or plan item id interchangeably; querying the wrong CMMN database/schema in multi-datasource setups.
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
- plan item instance ${planItemInstanceId} doesn't exist
- plan item instance ${planItemInstanceId} doesn't exist
- No case instance found for id ${caseInstanceId}
- No case instance found for id ${caseInstanceId}
- Plan item instance '${id}' does not have a variable '${varia
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/c9ba7dd4303302d1.
Report an issue: GitHub.