{"record":{"id":"579d3eace28f9445","repo":"flowable/flowable-engine","slug":"cannot-find-activity-activityid-in-proce","errorCode":null,"errorMessage":"Cannot find activity '\" + activityId + \"' in process definition with id '\" + bpmnModel.getMainProcess().getId() + \"'","messagePattern":"Cannot find activity '\" \\+ activityId \\+ \"' in process definition with id '\" \\+ bpmnModel\\.getMainProcess\\(\\)\\.getId\\(\\) \\+ \"'","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java","lineNumber":450,"sourceCode":"                if (bpmnModelToMigrateTo != null) {\n                \tnewFlowElement = resolveFlowElementFromBpmnModel(bpmnModelToMigrateTo, activityId);\n                } else {\n                \tnewFlowElement = resolveFlowElementFromBpmnModel(bpmnModel, activityId);\n                }\n            }\n\n            moveExecutionContainer.addMoveToFlowElement(activityId, currentFlowElement, newFlowElement);\n            moveExecutionContainer.addCurrentActivityToNewElement(currentActivityId, currentFlowElement, newFlowElement);\n            canContainerDirectMigrate = canContainerDirectMigrate && isDirectFlowElementExecutionMigration(currentFlowElement, newFlowElement);\n        }\n\n        moveExecutionContainer.setDirectExecutionMigration(canContainerDirectMigrate && migrateToProcessDefinition != null);\n    }\n\n    protected FlowElement resolveFlowElementFromBpmnModel(BpmnModel bpmnModel, String activityId) {\n        FlowElement flowElement = bpmnModel.getFlowElement(activityId);\n        if (flowElement == null) {\n            throw new FlowableIllegalArgumentException(\"Cannot find activity '\" + activityId + \"' in process definition with id '\" + bpmnModel.getMainProcess().getId() + \"'\");\n        }\n        return flowElement;\n    }\n    //-- Move container preparation section end\n\n    protected void doMoveExecutionState(ProcessInstanceChangeState processInstanceChangeState, CommandContext commandContext) {\n        ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext);\n        Map<String, List<ExecutionEntity>> activeEmbeddedSubProcesses = resolveActiveEmbeddedSubProcesses(processInstanceChangeState.getProcessInstanceId(), commandContext);\n        processInstanceChangeState.setProcessInstanceActiveEmbeddedExecutions(activeEmbeddedSubProcesses);\n\n        //Set the processInstance variables first so they are available during the change state\n        ExecutionEntity processInstanceExecution = executionEntityManager.findById(processInstanceChangeState.getProcessInstanceId());\n        processInstanceExecution.setVariables(processInstanceChangeState.getProcessInstanceVariables());\n\n        for (MoveExecutionEntityContainer moveExecutionContainer : processInstanceChangeState.getMoveExecutionEntityContainers()) {\n            prepareMoveExecutionEntityContainer(moveExecutionContainer, processInstanceChangeState.getProcessDefinitionToMigrateTo(), commandContext);\n            // Action the moves (changeState)\n            if (moveExecutionContainer.isMoveToParentProcess()) {","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java#L432-L468","documentation":"resolveFlowElementFromBpmnModel looks up the requested activity id in the BpmnModel of the (source or target) process definition. If bpmnModel.getFlowElement(activityId) returns null, the definition has no such flow element at the top level, so the move target/source is invalid.","triggerScenarios":"Passing an activityId to moveActivityIdTo/moveActivityId current flows that does not exist in the referenced process definition's BPMN model (or exists only nested and unresolvable at that level).","commonSituations":"Typos in activity ids; id exists in a different process definition version than the one being migrated to; activity inside a subprocess requiring a scoped lookup; deploying a changed BPMN that renamed the element.","solutions":["Verify the id exists in the deployed BPMN XML for that exact process definition id/version","Use the repositoryService.getBpmnModel(processDefinitionId) to enumerate valid flow element ids before the call","If the activity is inside a subprocess, use the appropriate scope-aware move operation"],"exampleFix":"// before\n.moveActivityIdTo(\"aprooveTask\", \"nextTask\")\n// after\nBpmnModel model = repositoryService.getBpmnModel(procDefId);\nif (model.getFlowElement(\"approveTask\") != null) { builder.moveActivityIdTo(\"approveTask\",\"nextTask\"); }","handlingStrategy":"validation","validationCode":"BpmnModel model = repositoryService.getBpmnModel(procDefId);\nif (model.getFlowElement(activityId) == null) throw new IllegalArgumentException(\"Unknown activity \" + activityId);","typeGuard":null,"tryCatchPattern":"try { builder.changeState(); } catch (FlowableIllegalArgumentException e) { if (e.getMessage().startsWith(\"Cannot find activity\")) { /* fix ids */ } else throw e; }","preventionTips":["Validate all move ids against the exact definition version's BpmnModel","Keep element ids stable when redeploying BPMN","Remember nested subprocess elements may need scoped lookup"],"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"}