{"record":{"id":"01b246f39d912e95","repo":"flowable/flowable-engine","slug":"cannot-trigger-process-task-plan-item-instance-r","errorCode":null,"errorMessage":"Cannot trigger process task plan item instance : reference type '","messagePattern":"Cannot trigger process task plan item instance : reference type '","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/ProcessTaskActivityBehavior.java","lineNumber":169,"sourceCode":"            processInstanceService.startProcessInstance(processDefinitionId, processInstanceId, planItemInstanceEntity.getStageInstanceId(),\n                    planItemInstanceEntity.getTenantId(), inParametersMap, businessKey, variableFormVariables, variableFormInfo, variableFormOutcome);\n        }\n\n        if (!blocking) {\n            CommandContextUtil.getAgenda(commandContext).planCompletePlanItemInstanceOperation(planItemInstanceEntity);\n        }\n    }\n\n    @Override\n    public void trigger(CommandContext commandContext, PlanItemInstanceEntity planItemInstance) {\n        if (!PlanItemInstanceState.ACTIVE.equals(planItemInstance.getState())) {\n            throw new FlowableIllegalStateException(\"Can only trigger a plan item that is in the ACTIVE state\");\n        }\n        if (planItemInstance.getReferenceId() == null) {\n            throw new FlowableIllegalStateException(\"Cannot trigger process task plan item instance : no reference id set\");\n        }\n        if (!ReferenceTypes.PLAN_ITEM_CHILD_PROCESS.equals(planItemInstance.getReferenceType())) {\n            throw new FlowableException(\"Cannot trigger process task plan item instance : reference type '\"\n                    + planItemInstance.getReferenceType() + \"' not supported for \" + planItemInstance);\n        }\n\n        // Need to be set before planning the complete operation\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        CaseInstanceEntity caseInstance = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(planItemInstance.getCaseInstanceId());\n        handleOutParameters(planItemInstance, caseInstance, cmmnEngineConfiguration.getProcessInstanceService());\n\n        // Triggering the plan item (as opposed to a regular complete) terminates the process instance\n        CommandContextUtil.getAgenda(commandContext).planCompletePlanItemInstanceOperation(planItemInstance);\n        deleteProcessInstance(commandContext, planItemInstance);\n    }\n\n    @Override\n    public void onStateTransition(CommandContext commandContext, DelegatePlanItemInstance planItemInstance, String transition) {\n        if (PlanItemInstanceState.ACTIVE.equals(planItemInstance.getState())) {\n            // The process task plan item will be deleted by the regular TerminatePlanItemOperation\n            if (PlanItemTransition.TERMINATE.equals(transition) || PlanItemTransition.EXIT.equals(transition)) {","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/ProcessTaskActivityBehavior.java#L151-L187","documentation":"The trigger path validates that a process task plan item is backed by a child BPMN process instance via referenceType == PLAN_ITEM_CHILD_PROCESS. Any other reference type (or a mismatched one) makes the trigger invalid, and Flowable throws a FlowableException including the offending reference type.","triggerScenarios":"trigger() called on a plan item whose referenceType is not PLAN_ITEM_CHILD_PROCESS — e.g. the plan item references a child case (PLAN_ITEM_CHILD_CASE) or another entity, and process-task completion logic is applied to it by mistake.","commonSituations":"Shared completion code that triggers plan items of multiple task types; a case model changed from a process task to a case task while old trigger code remained; event/callback listener registered for the wrong plan item definition.","solutions":["Check planItemInstance.getReferenceType() before triggering and only call process-task trigger logic for PLAN_ITEM_CHILD_PROCESS","Route case-task vs process-task completion through the correct behavior/service methods","Fix model/code mismatch: if the plan item became a case task, use the case-task trigger path instead","Include the plan item definition/type in logs to trace which listener triggers the wrong path"],"exampleFix":"// before\nprocessTaskBehavior.trigger(commandContext, planItemInstance); // assumes process task\n// after\nif (ReferenceTypes.PLAN_ITEM_CHILD_PROCESS.equals(planItemInstance.getReferenceType())) {\n    processTaskBehavior.trigger(commandContext, planItemInstance);\n} else {\n    // route to case-task / generic handling\n}","handlingStrategy":"type-guard","validationCode":"if (!\"planItemChildProcess\".equals(planItemInstance.getReferenceType())) {\n    throw new IllegalArgumentException(\"Not a process-task plan item: \" + planItemInstance.getId());\n}","typeGuard":"function isProcessTaskChild(pii) { return 'planItemChildProcess'.equalsIgnoreCase(pii.getReferenceType()); }","tryCatchPattern":"try {\n    processTaskTrigger(planItem);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"reference type\")) {\n        // route to the appropriate behavior for the actual reference type\n    }\n}","preventionTips":["Branch trigger/completion logic on referenceType","Keep model task types in sync with generic trigger code","Use distinct listeners per plan item definition type","Test models after converting process tasks to case tasks"],"tags":["cmmn","plan-item","reference-type","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}