flowable/flowable-engine · error · ActivitiException
Activity ${modelActivity.getId()} needed for multi instance
Error message
Activity ${modelActivity.getId()} needed for multi instance cannot bv found What it means
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.
Source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/parser/handler/AbstractActivityBpmnParseHandler.java:49
@Override
public void parse(BpmnParse bpmnParse, BaseElement element) {
super.parse(bpmnParse, element);
if (element instanceof Activity
&& ((Activity) element).getLoopCharacteristics() != null) {
createMultiInstanceLoopCharacteristics(bpmnParse, (Activity) element);
}
}
protected void createMultiInstanceLoopCharacteristics(BpmnParse bpmnParse, Activity modelActivity) {
MultiInstanceLoopCharacteristics loopCharacteristics = modelActivity.getLoopCharacteristics();
// Activity Behavior
MultiInstanceActivityBehavior miActivityBehavior = null;
ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(modelActivity.getId());
if (activity == null) {
throw new ActivitiException("Activity " + modelActivity.getId() + " needed for multi instance cannot bv found");
}
if (loopCharacteristics.isSequential()) {
miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createSequentialMultiInstanceBehavior(
activity, activity.getActivityBehavior());
} else {
miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createParallelMultiInstanceBehavior(
activity, activity.getActivityBehavior());
}
// ActivityImpl settings
activity.setScope(true);
activity.setProperty("multiInstance", loopCharacteristics.isSequential() ? "sequential" : "parallel");
activity.setActivityBehavior(miActivityBehavior);
ExpressionManager expressionManager = bpmnParse.getExpressionManager();
// loop cardinalityView on GitHub (pinned to d6d39ce1c6)
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
Example fix
// before (BPMN) <subProcess id="sp1"><task id="wrongId"><multiInstanceLoopCharacteristics .../></task></subProcess> // after <subProcess id="sp1"><task id="taskA"><multiInstanceLoopCharacteristics .../></task></subProcess>
Defensive patterns
Strategy: validation
Validate before calling
// before deployment, parse BPMN and verify multi-instance ids exist in scope
for (String miActivityId : multiInstanceActivityIds) {
if (!bpmnModel.getFlowElementIdsOfMainProcess().contains(miActivityId)
&& !existsInAnySubprocess(bpmnModel, miActivityId)) {
throw new IllegalStateException("Multi-instance activity not found: " + miActivityId);
}
} Try / catch
try {
repositoryService.createDeployment().addInputStream(name, xml).deploy();
} catch (ActivitiException e) {
if (e.getMessage().contains("needed for multi instance")) {
throw new DeploymentValidationException("Fix multi-instance activity id/scope in BPMN XML", e);
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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
- The default BPMN parse handlers should only support one type
- Error while parsing BPMN model.
- Errors while parsing:\n" + errorBuilder
- Error parsing XML
- invalid: multiple sources " + this.streamSource + " and " +
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/1f690d3ec62fb5b5.
Report an issue: GitHub.