flowable/flowable-engine · error · FlowableObjectNotFoundException
Cannot find plan item instance with id
Error message
Cannot find plan item instance with id
What it means
Thrown by GetIdentityLinksForPlanItemInstanceCmd when no PlanItemInstance exists with the given id. The command fetches the plan item via PlanItemInstanceEntityManager.findById and throws FlowableObjectNotFoundException when null. Plan item instances disappear when their parent case completes or the plan item is terminated/completed.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetIdentityLinksForPlanItemInstanceCmd.java:48
*/
public class GetIdentityLinksForPlanItemInstanceCmd implements Command<List<IdentityLink>>, Serializable {
private static final long serialVersionUID = 1L;
protected String planItemInstanceId;
public GetIdentityLinksForPlanItemInstanceCmd(String planItemInstanceId) {
this.planItemInstanceId = planItemInstanceId;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public List<IdentityLink> execute(CommandContext commandContext) {
CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
PlanItemInstance planItemInstance = cmmnEngineConfiguration.getPlanItemInstanceEntityManager().findById(planItemInstanceId);
if (planItemInstance == null) {
throw new FlowableObjectNotFoundException("Cannot find plan item instance with id " + planItemInstanceId, PlanItemInstanceEntity.class);
}
return (List) cmmnEngineConfiguration.getIdentityLinkServiceConfiguration().getIdentityLinkService()
.findIdentityLinksBySubScopeIdAndType(planItemInstanceId, ScopeTypes.PLAN_ITEM);
}
}
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Re-query the plan item first: cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(id).count() > 0.
- Refresh the id from the live case (createPlanItemInstanceQuery().caseInstanceId(caseId).list()).
- If the case ended, switch to history queries (cmmnHistoryService) for the plan item data.
- Validate id type/length at input boundaries to catch misuse of foreign keys.
Example fix
// before
List<IdentityLink> links = cmmnRuntimeService.getIdentityLinksForPlanItemInstance(planItemId);
// after
PlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(planItemId).singleResult();
if (pii == null) { throw new IllegalStateException("Plan item gone: " + planItemId); }
List<IdentityLink> links = cmmnRuntimeService.getIdentityLinksForPlanItemInstance(planItemId); Defensive patterns
Strategy: validation
Validate before calling
if (cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(planItemInstanceId).count() == 0) {
throw new IllegalArgumentException("Unknown plan item instance id: " + planItemInstanceId);
} Type guard
boolean planItemInstanceAlive(String id) {
return cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceId(id).count() > 0;
} Try / catch
try {
links = cmmnRuntimeService.getIdentityLinksForPlanItemInstance(planItemInstanceId);
} catch (FlowableObjectNotFoundException e) {
log.warn("Plan item {} no longer exists", planItemInstanceId);
links = Collections.emptyList();
} Prevention
- Re-fetch plan item ids from the live case before use
- Expect ids to vanish on case completion/termination
- Use history APIs for past plan items
- Validate id source/type at boundaries
When it happens
Trigger: Calling identity-link APIs for a plan item whose parent case already ended, using a stale plan item id captured before the case moved on, or passing a case instance id / stage id where a plan item instance id is expected.
Common situations: Async clients caching plan item ids too long; querying after a terminate/delete of the case; copying the wrong id from logs or the ACT_/FLW_ tables; unit tests reusing ids across runs.
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 plan item instance for id ${planItemInstanceId}
- plan item instance ${planItemInstanceId} doesn't exist
- Can only trigger a plan item that is in the ACTIVE state
- Cannot find case instance for id ${caseInstanceId}
- Plan item instance id is null
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/45682555a5f54dd4.
Report an issue: GitHub.