flowable/flowable-engine · error · ActivitiException

Could not execute inner activity behavior of multi instance…

Error message

Could not execute inner activity behavior of multi instance behavior

What it means

Wraps any exception thrown by the inner activity behavior of a sequential multi-instance activity during executeOriginalBehavior, except BpmnError which is re-thrown for error-event handling. It indicates the delegate/service inside one loop iteration failed, hiding the root cause as the cause of this ActivitiException.

Solutions

  1. Inspect the full stack trace's 'Caused by' chain — the real failure is the wrapped cause, not this message
  2. Fix the root-cause exception in the inner delegate/behavior for the failing iteration
  3. If the inner failure is a business error, throw a BpmnError from the delegate so it propagates to an error boundary/sub-process instead of being wrapped
  4. Add error boundary events or a try/catch inside the delegate to control loop-failure semantics

Example fix

// before (delegate throws raw exception)
public void execute(DelegateExecution exec) {
    throw new RuntimeException("bad data: " + exec.getVariable("payload"));
}
// after
public void execute(DelegateExecution exec) {
    String payload = (String) exec.getVariable("payload");
    if (payload == null) {
        throw new BpmnError("INVALID_PAYLOAD", "payload missing for iteration");
    }
}
Defensive patterns

Strategy: validation

Validate before calling

// Ensure inner delegates validate inputs before execution
if (execution.getVariable("loopCounter") == null) {
    throw new BpmnError("MISSING_LOOP_COUNTER");
}

Try / catch

try {
    runtimeService.startProcessInstanceByKey("process");
} catch (ActivitiException e) {
    log.error("Multi-instance inner behavior failed: ", e.getCause());
}

Prevention

When it happens

Trigger: Any exception thrown while executing the wrapped behavior of a loop iteration — e.g. a JavaDelegate throwing RuntimeException, a service task failing to resolve its expression, an NPE in a listener — inside SequentialMultiInstanceBehavior.leave.

Common situations: A delegate class throws due to bad input data in one iteration; a service-task expression references a missing variable or bean; an HTTP/DB call inside a delegate fails mid-loop; developers miss the nested 'Caused by' when reading logs.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/SequentialMultiInstanceBehavior.java:83

        if (loopCounter != nrOfInstances && !completionConditionSatisfied(execution)) {
            callActivityEndListeners(execution);
        }

        setLoopVariable(execution, getCollectionElementIndexVariable(), loopCounter);
        setLoopVariable(execution, NUMBER_OF_COMPLETED_INSTANCES, nrOfCompletedInstances);
        logLoopDetails(execution, "instance completed", loopCounter, nrOfCompletedInstances, nrOfActiveInstances, nrOfInstances);

        if (loopCounter >= nrOfInstances || completionConditionSatisfied(execution)) {
            super.leave(execution);
        } else {
            try {
                executeOriginalBehavior(execution, loopCounter);
            } catch (BpmnError error) {
                // re-throw business fault so that it can be caught by an Error Intermediate Event or Error Event Sub-Process in the process
                throw error;
            } catch (Exception e) {
                throw new ActivitiException("Could not execute inner activity behavior of multi instance behavior", e);
            }
        }
    }

    @Override
    public void execute(DelegateExecution execution) {
        super.execute(execution);

        if (innerActivityBehavior instanceof SubProcessActivityBehavior) {
            // ACT-1185: end-event in subprocess may have inactivated execution
            if (!execution.isActive() && execution.isEnded() && (execution.getExecutions() == null || execution.getExecutions().isEmpty())) {
                execution.setActive(true);
            }
        }
    }

}

View on GitHub (pinned to d6d39ce1c6)