flowable/flowable-engine · error · ActivitiException

No initial activity found for subprocess %s

Error message

No initial activity found for subprocess %s

What it means

Thrown when a subprocess (embedded sub-process) scope is entered but its model has no activity marked as the initial activity (BpmnParse.PROPERTYNAME_INITIAL is null). The parser normally derives the initial activity from a start event; its absence means the subprocess definition is incomplete or the parse didn't set it. Execution cannot proceed without a place to start inside the subprocess.

Source

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

import org.activiti.engine.impl.pvm.delegate.CompositeActivityBehavior;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.flowable.engine.delegate.DelegateExecution;

/**
 * Implementation of the BPMN 2.0 subprocess (formally known as 'embedded' subprocess): a subprocess defined within another process definition.
 * 
 * @author Joram Barrez
 */
public class SubProcessActivityBehavior extends AbstractBpmnActivityBehavior implements CompositeActivityBehavior {

    @Override
    public void execute(DelegateExecution execution) {
        ActivityExecution activityExecution = (ActivityExecution) execution;
        PvmActivity activity = activityExecution.getActivity();
        ActivityImpl initialActivity = (ActivityImpl) activity.getProperty(BpmnParse.PROPERTYNAME_INITIAL);

        if (initialActivity == null) {
            throw new ActivitiException("No initial activity found for subprocess "
                    + activityExecution.getActivity().getId());
        }

        // initialize the template-defined data objects as variables
        initializeDataObjects(activityExecution, activity);

        if (initialActivity.getActivityBehavior() != null
                && initialActivity.getActivityBehavior() instanceof NoneStartEventActivityBehavior) { // embedded subprocess: only none start allowed
            ((ExecutionEntity) execution).setActivity(initialActivity);
            Context.getCommandContext().getHistoryManager().recordActivityStart((ExecutionEntity) execution);
        }

        activityExecution.executeActivity(initialActivity);
    }

    @Override
    public void lastExecutionEnded(ActivityExecution execution) {
        ScopeUtil.createEventScopeExecution((ExecutionEntity) execution);

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Open the BPMN XML and add a valid (none) start event inside the embedded subprocess, connected to the first flow node.
  2. Validate the process definition with the modeler/validator so the subprocess start event is correctly nested inside the subProcess element.
  3. If building the model programmatically, call activity.setProperty(BpmnParse.PROPERTYNAME_INITIAL, initialActivity) on the subprocess scope.
  4. Redeploy a corrected process definition and start a fresh process instance (old instances may need migration).

Example fix

// before
<subProcess id="sub1">
  <task id="inner"/>
</subProcess>
// after
<subProcess id="sub1">
  <startEvent id="sub1Start"/>
  <sequenceFlow sourceRef="sub1Start" targetRef="inner"/>
  <task id="inner"/>
</subProcess>
Defensive patterns

Strategy: validation

Validate before calling

// at deployment time
ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("myProcess").latestVersion().singleResult();
BpmnModel model = repositoryService.getBpmnModel(pd.getId());
Process proc = model.getMainProcess();
proc.getFlowElementsOfType(SubProcess.class).forEach(sub ->
    assertHasStartEvent(sub)); // fail deploy if a subprocess lacks a start event

Try / catch

try {
    runtimeService.startProcessInstanceByKey("myProcess");
} catch (ActivitiException e) {
    if (e.getMessage().startsWith("No initial activity found for subprocess")) {
        log.error("Subprocess {} is missing a start event; fix BPMN XML", e.getMessage());
        throw new InvalidProcessDefinitionException(e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Entering an embedded subprocess whose parsed ActivityImpl has no PROPERTYNAME_INITIAL property — e.g. the subprocess BPMN XML lacks an proper none start event / start-event placement, or the model was built programmatically without setting the initial activity via activity.setProperty(BpmnParse.PROPERTYNAME_INITIAL, ...).

Common situations: BPMN XML where the subprocess's start event is malformed, attached incorrectly, or missing so the parser can't determine the initial activity; dynamically-built or transformed process models that skip setting the initial activity; importing diagrams produced by tools that omit subprocess start events.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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