flowable/flowable-engine · error · FlowableException

Plan item instance not found for id

Error message

Plan item instance not found for id 

What it means

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.

Source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/RescheduleTimerJobCmd.java:86

                throw new FlowableException("Multiple timer jobs found for plan item instance " + eventListenerInstanceId);
            }
            
            timerJobId = timerJobs.get(0).getId();
        
        } else {
            timerJobId = jobId;
        }
        
        TimerJobService timerJobService = CommandContextUtil.getTimerJobService(commandContext);
        TimerJobEntity timerJob = timerJobService.findTimerJobById(timerJobId);
        if (timerJob == null) {
            throw new FlowableObjectNotFoundException("Timer job not found for id " + timerJobId);
        }
        
        if (planItemInstance == null) {
            planItemInstance = CommandContextUtil.getPlanItemInstanceEntityManager(commandContext).findById(timerJob.getSubScopeId());
            if (planItemInstance == null) {
                throw new FlowableException("Plan item instance not found for id " + timerJob.getSubScopeId());
            }
        }
        
        Date timerDueDate = null;
        boolean isRepeating = false;
        if (newDueDate != null) {
            timerDueDate = newDueDate;
            
        } else if (newDateValue != null) {
            BusinessCalendarManager businessCalendarManager = CommandContextUtil.getCmmnEngineConfiguration(commandContext).getBusinessCalendarManager();
            if (isDurationString(newDateValue)) {
                timerDueDate = businessCalendarManager.getBusinessCalendar(DueDateBusinessCalendar.NAME).resolveDuedate(newDateValue);

            } else if (isRepetitionString(newDateValue)) {
                timerDueDate = businessCalendarManager.getBusinessCalendar(CycleBusinessCalendar.NAME).resolveDuedate(newDateValue);
                isRepeating = true;

            } else {

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Re-query the plan item instance / case before rescheduling to confirm it is still active
  2. Treat completed cases as terminal: reject reschedule requests for finished cases in application logic
  3. Check job.subScopeId consistency in the ACT_RU_* tables if you suspect corruption
  4. Restore consistent state from backup or redeploy the case if data is corrupt

Example fix

// before
cmmnRuntimeService.setTimerJobDueDate(jobId, newDueDate); // plan item already completed
// after
PlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery().id(planItemInstanceId).singleResult();
if (pii != null && pii.getState() == PlanItemInstanceState.ACTIVE) {
    cmmnRuntimeService.setTimerJobDueDate(jobId, newDueDate);
}
Defensive patterns

Strategy: validation

Validate before calling

PlanItemInstance pii = cmmnRuntimeService.createPlanItemInstanceQuery().id(piiId).singleResult();
if (pii == null) throw new IllegalStateException("Plan item instance gone: " + piiId);

Try / catch

try { runtimeService.setTimerJobDueDate(jobId, due); } catch (FlowableException e) { log.warn("Parent plan item instance no longer exists", e); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/4b8fc214a8234184. Report an issue: GitHub.