{"record":{"id":"1ae3d43d37e4269d","repo":"flowable/flowable-engine","slug":"could-not-find-a-cmmnelement-for-id-planiteminst","errorCode":null,"errorMessage":"Could not find a CmmnElement for id ${planItemInstance.getPlanItem().getId()}","messagePattern":"Could not find a CmmnElement for id (.+?)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/delegate/CmmnDelegateHelper.java","lineNumber":61,"sourceCode":"     * Returns the {@link CmmnModel} matching the case definition cmmn model for the case definition of the passed {@link DelegatePlanItemInstance}.\n     */\n    public static CmmnModel getCmmnModel(DelegatePlanItemInstance  planItemInstance) {\n        if (planItemInstance == null) {\n            throw new  FlowableException(\"Null planItemInstance passed\");\n        }\n        return CaseDefinitionUtil.getCmmnModel(planItemInstance.getCaseDefinitionId());\n    }\n\n    /**\n     * Returns the current {@link CmmnElement} where the {@link DelegatePlanItemInstance} is currently at.\n     */\n    public static CmmnElement getCmmnElement(DelegatePlanItemInstance planItemInstance) {\n        CmmnModel cmmnModel =  getCmmnModel(planItemInstance);\n        CaseElement caseElement = null;\n        if (planItemInstance.getPlanItem() != null) {\n            caseElement = cmmnModel.getPrimaryCase().getAllCaseElements().get(planItemInstance.getPlanItem().getId());\n            if (caseElement == null) {\n                throw new FlowableException(\"Could not find a CmmnElement for id \" + planItemInstance.getPlanItem().getId());\n            }\n        }\n        return caseElement;\n    }\n\n    public static boolean isExecutingLifecycleListener(DelegatePlanItemInstance planItemInstance) {\n        // Need to check the lifecycle listener, not the model listener (as it could be a lifecycle listener set on the config level)\n        return planItemInstance.getCurrentLifecycleListener() != null;\n    }\n\n    public static Map<String, List<ExtensionElement>> getExtensionElements(DelegatePlanItemInstance planItemInstance) {\n        if (isExecutingLifecycleListener(planItemInstance)) {\n            return getListenerExtensionElements(planItemInstance);\n        } else {\n            return getCmmnElementExtensionElements(planItemInstance);\n        }\n    }\n","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/delegate/CmmnDelegateHelper.java#L43-L79","documentation":"After resolving the CMMN model, getCmmnElement looks up the CmmnElement for the plan item's id in the primary case's element map. If the plan item exists at runtime but no matching CmmnElement is found in the model (and getPlanItem() is non-null), this FlowableException is thrown. Note the helper returns null silently when getPlanItem() is null, but throws when the id is not in the model.","triggerScenarios":"Custom code calls CmmnDelegateHelper.getCmmnElement(planItemInstance) while the plan item's id cannot be found in cmmnModel.getPrimaryCase().getAllCaseElements() — e.g. the deployed model version differs from the running case definition, or the id lookup fails for dynamically created/child plan items.","commonSituations":"Running cases against an outdated cached CMMN model after a redeploy; lookups for plan items not present as case elements (e.g. certain generated/child instances); case definition id mismatch between tenant/deployment versions.","solutions":["Verify the case definition deployment matches the model: redeploy cleanly and restart cases so the running case uses the current model version.","Guard the helper call: use planItemInstance.getPlanItem() null-checks and treat missing CmmnElement as optional in your delegate.","Use CmmnDelegateHelper.getCmmnModel(planItemInstance) and inspect getAllCaseElements() keys to confirm the expected id is present.","Check caseDefinitionId consistency (same deployment/tenant) between the running case and the resolved model."],"exampleFix":"// before\nCmmnElement el = CmmnDelegateHelper.getCmmnElement(planItemInstance); // may throw\n// after\nCmmnElement el = null;\nif (planItemInstance.getPlanItem() != null) {\n  el = CmmnDelegateHelper.getCmmnModel(planItemInstance)\n      .getPrimaryCase().getAllCaseElements().get(planItemInstance.getPlanItem().getId());\n}\nif (el != null) { ... }","handlingStrategy":"try-catch","validationCode":"CmmnModel model = CmmnDelegateHelper.getCmmnModel(planItemInstance);\nboolean present = planItemInstance.getPlanItem() != null\n    && model.getPrimaryCase().getAllCaseElements().containsKey(planItemInstance.getPlanItem().getId());","typeGuard":"CmmnElement findElementOrNull(DelegatePlanItemInstance p) {\n    try { return CmmnDelegateHelper.getCmmnElement(p); }\n    catch (org.flowable.common.engine.api.FlowableException e) { return null; }\n}","tryCatchPattern":"try {\n    CmmnElement el = CmmnDelegateHelper.getCmmnElement(planItemInstance);\n} catch (org.flowable.common.engine.api.FlowableException e) {\n    if (e.getMessage().startsWith(\"Could not find a CmmnElement\")) { log.warn(\"Element missing in model: {}\", e.getMessage()); el = null; }\n    else throw e;\n}","preventionTips":["Keep running cases in sync with deployed model versions; avoid mutating model ids after deployment.","Treat CmmnElement lookups as optional in delegates — some plan items may not map to case elements.","Log the plan item id and caseDefinitionId to diagnose stale-model mismatches."],"tags":["java","cmmn","cmmn-model","flowable"],"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-18T11:17:12.947Z"}