flowable/flowable-engine · error · FlowableObjectNotFoundException
No plan item instance found for id ${planItemInstanceId}
Error message
No plan item instance found for id ${planItemInstanceId} What it means
Thrown by SetLocalVariablesCmd.execute when no plan item instance exists with the given id in the CMMN engine database. Flowable looks up the PlanItemInstanceEntity via findById and raises FlowableObjectNotFoundException if absent, so the local variables cannot be set.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetLocalVariablesCmd.java:51
this.planItemInstanceId = planItemInstanceId;
this.variables = variables;
}
@Override
public Void execute(CommandContext commandContext) {
if (planItemInstanceId == null) {
throw new FlowableIllegalArgumentException("planItemInstanceId is null");
}
if (variables == null) {
throw new FlowableIllegalArgumentException("variables is null");
}
if (variables.isEmpty()) {
throw new FlowableIllegalArgumentException("variables is empty");
}
PlanItemInstanceEntity planItemInstanceEntity = CommandContextUtil.getPlanItemInstanceEntityManager(commandContext).findById(planItemInstanceId);
if (planItemInstanceEntity == null) {
throw new FlowableObjectNotFoundException("No plan item instance found for id " + planItemInstanceId, PlanItemInstanceEntity.class);
}
planItemInstanceEntity.setVariablesLocal(variables);
CommandContextUtil.getAgenda(commandContext).planEvaluateCriteriaOperation(planItemInstanceEntity.getCaseInstanceId());
return null;
}
}
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Verify the planItemInstanceId is correct and fetch it via a plan item instance query for the live case instance
- Check that the plan item instance is still active (not completed/terminated) before setting variables
- Confirm the command runs against the same engine/database that owns the plan item instance
- Catch FlowableObjectNotFoundException and handle the missing-id case explicitly
Example fix
// before
runtimeService.setLocalVariables(stalePlanItemInstanceId, vars);
// after
PlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery()
.caseInstanceId(caseInstanceId).planItemInstanceStateActive().singleResult();
if (pii != null) {
cmmnRuntimeService.setLocalVariables(pii.getId(), vars);
} Defensive patterns
Strategy: validation
Validate before calling
if (planItemInstanceId == null || planItemInstanceId.trim().isEmpty()) {
throw new IllegalArgumentException("planItemInstanceId required");
}
PlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery()
.planItemInstanceId(planItemInstanceId).singleResult();
if (pii == null) throw new IllegalArgumentException("Unknown plan item instance: " + planItemInstanceId); Type guard
boolean planItemInstanceExists(String id) {
return id != null && cmmnRuntimeService.createPlanItemInstanceQuery()
.planItemInstanceId(id).count() > 0;
} Try / catch
try {
cmmnRuntimeService.setLocalVariables(planItemInstanceId, vars);
} catch (FlowableObjectNotFoundException e) {
log.warn("Plan item instance {} not found", planItemInstanceId, e);
} Prevention
- Always resolve plan item instance ids from a live query, never hardcode them
- Check plan item state (active) before writing local variables
- Reuse the same engine configuration/database across calls
When it happens
Trigger: Calling RuntimeService/CaseService setLocalVariables (or the SetLocalVariablesCmd command directly) with a planItemInstanceId that does not exist, was already completed/removed, or belongs to a different engine/database.
Common situations: Stale or hardcoded plan item instance ids, referencing an id from another case instance or environment, calling after the plan item terminated, or pointing at a case DB that was cleaned/redeployed.
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 plan item instance found for id ${planItemInstanceId}
- Cannot find case instance for id ${caseInstanceId}
- Cannot find plan item instance for id ${planItemInstanceId}
- Cannot find task with id ${taskId}
- Cannot find case instance with id
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/2ded42697c2d2858.
Report an issue: GitHub.