{"record":{"id":"adab6650287cb311","repo":"flowable/flowable-engine","slug":"no-initial-activity-found-for-subprocess-s","errorCode":null,"errorMessage":"No initial activity found for subprocess %s","messagePattern":"No initial activity found for subprocess (.+?)","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/SubProcessActivityBehavior.java","lineNumber":43,"sourceCode":"import org.activiti.engine.impl.pvm.delegate.CompositeActivityBehavior;\nimport org.activiti.engine.impl.pvm.process.ActivityImpl;\nimport org.flowable.engine.delegate.DelegateExecution;\n\n/**\n * Implementation of the BPMN 2.0 subprocess (formally known as 'embedded' subprocess): a subprocess defined within another process definition.\n * \n * @author Joram Barrez\n */\npublic class SubProcessActivityBehavior extends AbstractBpmnActivityBehavior implements CompositeActivityBehavior {\n\n    @Override\n    public void execute(DelegateExecution execution) {\n        ActivityExecution activityExecution = (ActivityExecution) execution;\n        PvmActivity activity = activityExecution.getActivity();\n        ActivityImpl initialActivity = (ActivityImpl) activity.getProperty(BpmnParse.PROPERTYNAME_INITIAL);\n\n        if (initialActivity == null) {\n            throw new ActivitiException(\"No initial activity found for subprocess \"\n                    + activityExecution.getActivity().getId());\n        }\n\n        // initialize the template-defined data objects as variables\n        initializeDataObjects(activityExecution, activity);\n\n        if (initialActivity.getActivityBehavior() != null\n                && initialActivity.getActivityBehavior() instanceof NoneStartEventActivityBehavior) { // embedded subprocess: only none start allowed\n            ((ExecutionEntity) execution).setActivity(initialActivity);\n            Context.getCommandContext().getHistoryManager().recordActivityStart((ExecutionEntity) execution);\n        }\n\n        activityExecution.executeActivity(initialActivity);\n    }\n\n    @Override\n    public void lastExecutionEnded(ActivityExecution execution) {\n        ScopeUtil.createEventScopeExecution((ExecutionEntity) execution);","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/SubProcessActivityBehavior.java#L25-L61","documentation":"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.","triggerScenarios":"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, ...).","commonSituations":"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.","solutions":["Open the BPMN XML and add a valid (none) start event inside the embedded subprocess, connected to the first flow node.","Validate the process definition with the modeler/validator so the subprocess start event is correctly nested inside the subProcess element.","If building the model programmatically, call activity.setProperty(BpmnParse.PROPERTYNAME_INITIAL, initialActivity) on the subprocess scope.","Redeploy a corrected process definition and start a fresh process instance (old instances may need migration)."],"exampleFix":"// before\n<subProcess id=\"sub1\">\n  <task id=\"inner\"/>\n</subProcess>\n// after\n<subProcess id=\"sub1\">\n  <startEvent id=\"sub1Start\"/>\n  <sequenceFlow sourceRef=\"sub1Start\" targetRef=\"inner\"/>\n  <task id=\"inner\"/>\n</subProcess>","handlingStrategy":"validation","validationCode":"// at deployment time\nProcessDefinition pd = repositoryService.createProcessDefinitionQuery()\n    .processDefinitionKey(\"myProcess\").latestVersion().singleResult();\nBpmnModel model = repositoryService.getBpmnModel(pd.getId());\nProcess proc = model.getMainProcess();\nproc.getFlowElementsOfType(SubProcess.class).forEach(sub ->\n    assertHasStartEvent(sub)); // fail deploy if a subprocess lacks a start event","typeGuard":null,"tryCatchPattern":"try {\n    runtimeService.startProcessInstanceByKey(\"myProcess\");\n} catch (ActivitiException e) {\n    if (e.getMessage().startsWith(\"No initial activity found for subprocess\")) {\n        log.error(\"Subprocess {} is missing a start event; fix BPMN XML\", e.getMessage());\n        throw new InvalidProcessDefinitionException(e);\n    }\n    throw e;\n}","preventionTips":["Always include a (none) start event inside every embedded subprocess.","Run the BPMN validator/modeler validation before deploying definitions.","Avoid hand-editing generated BPMN XML where start events may be dropped.","When building models programmatically, explicitly set PROPERTYNAME_INITIAL on subprocess scopes.","Test process definitions end-to-end in CI before production deployment."],"tags":["bpmn","subprocess","process-definition","deploy"],"backgroundTag":"resource-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"}