{"record":{"id":"6d1d11d0ffb37300","repo":"flowable/flowable-engine","slug":"could-not-find-plan-item-instance-for-plan-item-wi","errorCode":null,"errorMessage":"Could not find plan item instance for plan item with definition id {planItemDefinitionId}","messagePattern":"Could not find plan item instance for plan item with definition id (.+?)","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/ReactivateCaseInstanceOperation.java","lineNumber":127,"sourceCode":"            .caseDefinitionId(planItemInstance.getCaseDefinitionId())\n            .caseInstanceId(planItemInstance.getCaseInstanceId())\n            .stagePlanItemInstance(stagePlanItem)\n            .tenantId(planItemInstance.getTenantId())\n            .addToParent(true)\n            .silentNameExpressionEvaluation(false)\n            .create();\n\n        CommandContextUtil.getAgenda(commandContext).planReactivatePlanItemInstanceOperation(reactivatedPlanItemInstance);\n        return reactivatedPlanItemInstance;\n    }\n\n    protected PlanItemInstanceEntity searchPlanItemInstance(String planItemDefinitionId, List<PlanItemInstanceEntity> planItemInstances) {\n        for (PlanItemInstanceEntity planItemInstance : planItemInstances) {\n            if (planItemInstance.getPlanItemDefinitionId().equals(planItemDefinitionId)) {\n                return planItemInstance;\n            }\n        }\n        throw new FlowableIllegalArgumentException(\"Could not find plan item instance for plan item with definition id \" + planItemDefinitionId);\n    }\n\n    @Override\n    public String toString() {\n        return \"[Init Plan Model] initializing plan model for case instance \" + caseInstanceEntity.getId();\n    }\n\n}\n","sourceCodeStart":109,"sourceCodeEnd":136,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/ReactivateCaseInstanceOperation.java#L109-L136","documentation":"searchPlanItemInstance scans the child plan item instances of a case for one whose planItemDefinitionId equals the requested id, and throws if none matches. It is used during case reactivation, both to find the reactivation listener and to reactivate dependent plan items.","triggerScenarios":"Reactivating a case where the ReactivateEventListener id or a depending plan item's id referenced by the reactivation logic does not match any child plan item instance (never created, already removed, or definition id changed after redeployment).","commonSituations":"Case model refactoring renamed a plan item id; suspension happened before dependent plan items existed; database contains plan item instances from an older case definition version.","solutions":["Check ACT_CMMN_RU_PLAN_ITEM_INST for the expected planItemDefinitionId in that case instance.","Align the case model plan item ids with the ones existing at suspension time; avoid renaming plan item ids of running cases.","Use the latest case definition consistently and migrate/restart affected case instances.","Wrap reactivation in try-catch for FlowableIllegalArgumentException and fall back to manual data repair."],"exampleFix":"// before: renamed planItem id 'approveTask' to 'approvalTask' in a running case\n// after: keep ids stable\n<planItem id=\"approveTask\" name=\"Approve\" .../>","handlingStrategy":"validation","validationCode":"// java\nPlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery()\n    .caseInstanceId(caseInstanceId)\n    .planItemDefinitionId(planItemDefinitionId).singleResult();\nif (pii == null) throw new IllegalStateException(\"Missing plan item instance: \" + planItemDefinitionId);","typeGuard":null,"tryCatchPattern":"try {\n    cmmnRuntimeService.resumeCaseInstance(caseInstanceId);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Could not find plan item instance\")) {\n        // inspect ACT_CMMN_RU_PLAN_ITEM_INST and repair\n    }\n}","preventionTips":["Keep plan item ids stable across case model versions.","Suspend/resume cases only after the plan model is fully initialized.","Audit runtime plan item instances before reactivation."],"tags":["cmmn","plan-item","reactivation"],"backgroundTag":"entity-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}