{"record":{"id":"1f690d3ec62fb5b5","repo":"flowable/flowable-engine","slug":"activity-modelactivity-getid-needed-for-multi","errorCode":null,"errorMessage":"Activity ${modelActivity.getId()} needed for multi instance cannot bv found","messagePattern":"Activity (.+?) needed for multi instance cannot bv found","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/parser/handler/AbstractActivityBpmnParseHandler.java","lineNumber":49,"sourceCode":"    @Override\n    public void parse(BpmnParse bpmnParse, BaseElement element) {\n        super.parse(bpmnParse, element);\n\n        if (element instanceof Activity\n                && ((Activity) element).getLoopCharacteristics() != null) {\n            createMultiInstanceLoopCharacteristics(bpmnParse, (Activity) element);\n        }\n    }\n\n    protected void createMultiInstanceLoopCharacteristics(BpmnParse bpmnParse, Activity modelActivity) {\n\n        MultiInstanceLoopCharacteristics loopCharacteristics = modelActivity.getLoopCharacteristics();\n\n        // Activity Behavior\n        MultiInstanceActivityBehavior miActivityBehavior = null;\n        ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(modelActivity.getId());\n        if (activity == null) {\n            throw new ActivitiException(\"Activity \" + modelActivity.getId() + \" needed for multi instance cannot bv found\");\n        }\n\n        if (loopCharacteristics.isSequential()) {\n            miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createSequentialMultiInstanceBehavior(\n                    activity, activity.getActivityBehavior());\n        } else {\n            miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createParallelMultiInstanceBehavior(\n                    activity, activity.getActivityBehavior());\n        }\n\n        // ActivityImpl settings\n        activity.setScope(true);\n        activity.setProperty(\"multiInstance\", loopCharacteristics.isSequential() ? \"sequential\" : \"parallel\");\n        activity.setActivityBehavior(miActivityBehavior);\n\n        ExpressionManager expressionManager = bpmnParse.getExpressionManager();\n\n        // loop cardinality","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/parser/handler/AbstractActivityBpmnParseHandler.java#L31-L67","documentation":"When parsing multi-instance loop characteristics, the parser resolves the activity by id within the current parse scope. If getCurrentScope().findActivity(modelActivity.getId()) returns null, the scope does not contain the activity needed for the multi-instance behavior, so BpmnParse throws this ActivitiException. Note the typo 'bv' for 'be' in the message.","triggerScenarios":"A BPMN XML with a multiInstanceLoopCharacteristics whose referenced/enclosing activity id cannot be resolved in the current scope — typically a nested/subprocess structure where the scope lookup misses the activity, or a malformed model where the loop characteristics were attached to an activity not present in the scope being parsed.","commonSituations":"Hand-edited BPMN XML with mismatched ids; models generated by tools that place multi-instance markers in the wrong scope; programmatic model building that adds loop characteristics before the activity is registered in the scope.","solutions":["Verify the activity id in the multiInstanceLoopCharacteristics matches an existing element id in the same scope (process or subprocess) of the BPMN XML","Fix nested-scope issues: ensure the multi-instance activity is a direct child of the correct subprocess/transaction element","Re-export the diagram from the BPMN modeler instead of hand-editing XML ids","If building the model programmatically, add the activity to the current scope before attaching MultiInstanceLoopCharacteristics"],"exampleFix":"// before (BPMN)\n<subProcess id=\"sp1\"><task id=\"wrongId\"><multiInstanceLoopCharacteristics .../></task></subProcess>\n// after\n<subProcess id=\"sp1\"><task id=\"taskA\"><multiInstanceLoopCharacteristics .../></task></subProcess>","handlingStrategy":"validation","validationCode":"// before deployment, parse BPMN and verify multi-instance ids exist in scope\nfor (String miActivityId : multiInstanceActivityIds) {\n  if (!bpmnModel.getFlowElementIdsOfMainProcess().contains(miActivityId)\n      && !existsInAnySubprocess(bpmnModel, miActivityId)) {\n    throw new IllegalStateException(\"Multi-instance activity not found: \" + miActivityId);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  repositoryService.createDeployment().addInputStream(name, xml).deploy();\n} catch (ActivitiException e) {\n  if (e.getMessage().contains(\"needed for multi instance\")) {\n    throw new DeploymentValidationException(\"Fix multi-instance activity id/scope in BPMN XML\", e);\n  } else throw e;\n}","preventionTips":["Keep multiInstanceLoopCharacteristics inside the element it configures","Avoid hand-editing BPMN XML ids; use a modeler","Validate the process with the Activiti model API before deployment","Check subprocess nesting when ids live inside embedded subprocesses"],"tags":["activiti","bpmn","parsing"],"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-14T11:17:12.474Z"}