flowable/flowable-engine · error · FlowableObjectNotFoundException
No plan item instance found for id
Error message
No plan item instance found for id ${planItemInstanceId} What it means
After validating inputs, SetLocalVariableCmd looks up the plan item instance via PlanItemInstanceEntityManager.findById(). If no row exists for the given id, it throws FlowableObjectNotFoundException naming the id and PlanItemInstanceEntity.class. The id was well-formed but does not correspond to any existing plan item instance.
Solutions
- Verify the case instance is still active and the plan item instance exists via CmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(id).singleResult().
- Confirm you are connected to the database where the case instance actually runs (not another environment).
- Guard against using ids of completed plan items; query history (CmmnHistoryService) if you need historical data instead.
Example fix
// before
cmmnRuntimeService.setLocalVariable(planItemId, "flag", true); // id may be stale
// after
PlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(planItemId).singleResult();
if (pii != null) {
cmmnRuntimeService.setLocalVariable(planItemId, "flag", true);
} Defensive patterns
Strategy: validation
Validate before calling
PlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery()
.planItemInstanceId(planItemId).singleResult();
if (pii == null) {
throw new IllegalStateException("Plan item instance " + planItemId + " does not exist (case may be completed)");
} Try / catch
try {
cmmnRuntimeService.setLocalVariable(planItemId, name, value);
} catch (FlowableObjectNotFoundException e) {
log.warn("Plan item instance {} not found; case may have ended: {}", planItemId, e.getMessage());
} Prevention
- Verify the case instance is active before mutating its plan items.
- Clean up or flag stored ids when a case instance terminates.
- Check environment/datasource consistency (test vs prod databases).
When it happens
Trigger: Calling CmmnRuntimeService.setLocalVariable with an id of a plan item instance that was deleted, belongs to a completed/terminated case (moved to history), was never created in this database, or an id from a different engine/table.
Common situations: Stale ids stored in external systems after the case instance ended, running against a different database/environment (test vs prod), reusing ids across Flowable versions or a cmmn vs process engine confusion.
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 definition for id:
- Cannot find case definition with id
- Cannot find case definition with id
- Cannot find case instance for id
- Cannot find case instance with id
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/9674bf5f26a75596.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetLocalVariableCmd.java:48
public SetLocalVariableCmd(String planItemInstanceId, String variableName, Object variableValue) {
this.planItemInstanceId = planItemInstanceId;
this.variableName = variableName;
this.variableValue = variableValue;
}
@Override
public Void execute(CommandContext commandContext) {
if (planItemInstanceId == null) {
throw new FlowableIllegalArgumentException("planItemInstanceId is null");
}
if (variableName == null) {
throw new FlowableIllegalArgumentException("variable name 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.setVariableLocal(variableName, variableValue);
CommandContextUtil.getAgenda(commandContext).planEvaluateCriteriaOperation(planItemInstanceEntity.getCaseInstanceId());
return null;
}
}
View on GitHub (pinned to d6d39ce1c6)