{"record":{"id":"4b8fc214a8234184","repo":"flowable/flowable-engine","slug":"plan-item-instance-not-found-for-id","errorCode":null,"errorMessage":"Plan item instance not found for id ","messagePattern":"Plan item instance not found for id ","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/RescheduleTimerJobCmd.java","lineNumber":86,"sourceCode":"                throw new FlowableException(\"Multiple timer jobs found for plan item instance \" + eventListenerInstanceId);\n            }\n            \n            timerJobId = timerJobs.get(0).getId();\n        \n        } else {\n            timerJobId = jobId;\n        }\n        \n        TimerJobService timerJobService = CommandContextUtil.getTimerJobService(commandContext);\n        TimerJobEntity timerJob = timerJobService.findTimerJobById(timerJobId);\n        if (timerJob == null) {\n            throw new FlowableObjectNotFoundException(\"Timer job not found for id \" + timerJobId);\n        }\n        \n        if (planItemInstance == null) {\n            planItemInstance = CommandContextUtil.getPlanItemInstanceEntityManager(commandContext).findById(timerJob.getSubScopeId());\n            if (planItemInstance == null) {\n                throw new FlowableException(\"Plan item instance not found for id \" + timerJob.getSubScopeId());\n            }\n        }\n        \n        Date timerDueDate = null;\n        boolean isRepeating = false;\n        if (newDueDate != null) {\n            timerDueDate = newDueDate;\n            \n        } else if (newDateValue != null) {\n            BusinessCalendarManager businessCalendarManager = CommandContextUtil.getCmmnEngineConfiguration(commandContext).getBusinessCalendarManager();\n            if (isDurationString(newDateValue)) {\n                timerDueDate = businessCalendarManager.getBusinessCalendar(DueDateBusinessCalendar.NAME).resolveDuedate(newDateValue);\n\n            } else if (isRepetitionString(newDateValue)) {\n                timerDueDate = businessCalendarManager.getBusinessCalendar(CycleBusinessCalendar.NAME).resolveDuedate(newDateValue);\n                isRepeating = true;\n\n            } else {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/RescheduleTimerJobCmd.java#L68-L104","documentation":"After the timer job is resolved, RescheduleTimerJobCmd loads the owning plan item instance via its subScopeId. If PlanItemInstanceEntityManager.findById returns null, the job points to a plan item instance that no longer exists, and a generic FlowableException is thrown.","triggerScenarios":"Rescheduling a timer job whose parent plan item instance was deleted (case/plan item completed and cleaned up) between job creation and reschedule; corrupt or manually tampered job rows pointing at nonexistent subScopeId.","commonSituations":"Case instance completed and history cleanup removed the plan item while a timer reschedule request was queued; manual database manipulation; migrating jobs between databases inconsistently.","solutions":["Re-query the plan item instance / case before rescheduling to confirm it is still active","Treat completed cases as terminal: reject reschedule requests for finished cases in application logic","Check job.subScopeId consistency in the ACT_RU_* tables if you suspect corruption","Restore consistent state from backup or redeploy the case if data is corrupt"],"exampleFix":"// before\ncmmnRuntimeService.setTimerJobDueDate(jobId, newDueDate); // plan item already completed\n// after\nPlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery().id(planItemInstanceId).singleResult();\nif (pii != null && pii.getState() == PlanItemInstanceState.ACTIVE) {\n    cmmnRuntimeService.setTimerJobDueDate(jobId, newDueDate);\n}","handlingStrategy":"validation","validationCode":"PlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery().id(piiId).singleResult();\nif (pii == null) throw new IllegalStateException(\"Plan item instance gone: \" + piiId);","typeGuard":null,"tryCatchPattern":"try { runtimeService.setTimerJobDueDate(jobId, due); } catch (FlowableException e) { log.warn(\"Parent plan item instance no longer exists\", e); }","preventionTips":["Reject reschedule requests for completed cases","Avoid manual edits of ACT_RU_* tables","Check case state before mutating jobs"],"tags":["cmmn","plan-item-instance","not-found"],"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"}