{"record":{"id":"cefd432ab85721aa","repo":"flowable/flowable-engine","slug":"could-not-find-element-for-activity-id-enablea","errorCode":null,"errorMessage":"could not find element for activity id \" + enableActivityId","messagePattern":"could not find element for activity id \" \\+ enableActivityId","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java","lineNumber":664,"sourceCode":"        \n        for (EnableActivityContainer enableActivityContainer : processInstanceChangeState.getEnableActivityContainers()) {\n            if (enableActivityContainer.getActivityIds() != null && !enableActivityContainer.getActivityIds().isEmpty()) {\n                BpmnModel bpmnModel = null;\n                ExecutionEntity parentExecution = executionEntityManager.findById(processInstanceChangeState.getProcessInstanceId());\n                if (processInstanceChangeState.getProcessDefinitionToMigrateTo() != null) {\n                    bpmnModel = ProcessDefinitionUtil.getBpmnModel(processInstanceChangeState.getProcessDefinitionToMigrateTo().getId());\n                    \n                } else {\n                    bpmnModel = ProcessDefinitionUtil.getBpmnModel(parentExecution.getProcessDefinitionId());\n                }\n                \n                ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n                ProcessInstanceHelper processInstanceHelper = processEngineConfiguration.getProcessInstanceHelper();\n                \n                for (String enableActivityId : enableActivityContainer.getActivityIds()) {\n                    FlowElement enableFlowElement = bpmnModel.getFlowElement(enableActivityId);\n                    if (enableFlowElement == null) {\n                        throw new FlowableException(\"could not find element for activity id \" + enableActivityId);\n                    }\n                    \n                    processInstanceHelper.processEventSubProcessStartEvent(enableFlowElement, parentExecution, processEngineConfiguration, commandContext);\n                }\n            }\n        }\n    }\n\n    protected void processPendingEventSubProcessesStartEvents(ProcessInstanceChangeState processInstanceChangeState, CommandContext commandContext) {\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        ProcessInstanceHelper processInstanceHelper = processEngineConfiguration.getProcessInstanceHelper();\n        EventSubscriptionService eventSubscriptionService = processEngineConfiguration.getEventSubscriptionServiceConfiguration().getEventSubscriptionService();\n        ManagementService managementService = processEngineConfiguration.getManagementService();\n\n        for (Map.Entry<? extends StartEvent, ExecutionEntity> pendingStartEventEntry : processInstanceChangeState.getPendingEventSubProcessesStartEvents().entrySet()) {\n            StartEvent startEvent = pendingStartEventEntry.getKey();\n            ExecutionEntity parentExecution = pendingStartEventEntry.getValue();\n            EventDefinition eventDefinition = startEvent.getEventDefinitions().isEmpty() ? null : startEvent.getEventDefinitions().get(0);","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java#L646-L682","documentation":"When re-enabling activities (move to an event subprocess / enable activity ids), each enableActivityId is looked up in the BpmnModel; if getFlowElement returns null the id does not exist in the model and the operation aborts.","triggerScenarios":"moveActivityIdTo... with an enableActivityContainer whose activity ids are absent from the current process definition's BPMN model (typo, wrong definition version, or id from another process).","commonSituations":"Ids copied from a different process diagram; definition redeployed with renamed event-subprocess start activities; case-sensitive id mismatch.","solutions":["Validate each enableActivityId against repositoryService.getBpmnModel(processDefinitionId).getFlowElement(id) before the call","Correct the activity ids in the enable container to match the deployed BPMN","Pin the correct process definition version so the ids exist in the resolved model"],"exampleFix":"// before\n.enableActivity(\"errorStart_1\") // not in model\n// after\nif (bpmnModel.getFlowElement(\"errorStartEvent1\") != null) { builder.enableActivity(\"errorStartEvent1\"); }","handlingStrategy":"validation","validationCode":"BpmnModel model = repositoryService.getBpmnModel(procDefId);\nfor (String id : enableActivityIds) {\n    if (model.getFlowElement(id) == null) throw new IllegalArgumentException(\"Unknown enable activity \" + id);\n}","typeGuard":null,"tryCatchPattern":"try { builder.changeState(); } catch (FlowableException e) { if (e.getMessage().startsWith(\"could not find element for activity id\")) { /* fix enable ids */ } else throw e; }","preventionTips":["Validate enable activity ids against the deployed BpmnModel before the call","Keep event-subprocess start activity ids stable across versions","Copy ids from the actual BPMN XML, not other diagrams"],"tags":["flowable","bpmn","not-found"],"backgroundTag":"record-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"}