{"record":{"id":"411746043ea7b607","repo":"flowable/flowable-engine","slug":"could-not-find-a-flowelement-for-activityid-activ","errorCode":null,"errorMessage":"Could not find a FlowElement for activityId <activityId> in <execution>","messagePattern":"Could not find a FlowElement for activityId <activityId> in <execution>","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/delegate/DelegateHelper.java","lineNumber":84,"sourceCode":"\n    /**\n     * Returns the {@link BpmnModel} matching the process definition bpmn model for the process definition of the passed {@link DelegateExecution}.\n     */\n    public static BpmnModel getBpmnModel(DelegateExecution execution) {\n        if (execution == null) {\n            throw new FlowableException(\"Null execution passed\");\n        }\n        return ProcessDefinitionUtil.getBpmnModel(execution.getProcessDefinitionId());\n    }\n\n    /**\n     * Returns the current {@link FlowElement} where the {@link DelegateExecution} is currently at.\n     */\n    public static FlowElement getFlowElement(DelegateExecution execution) {\n        BpmnModel bpmnModel = getBpmnModel(execution);\n        FlowElement flowElement = bpmnModel.getFlowElement(execution.getCurrentActivityId());\n        if (flowElement == null) {\n            throw new FlowableException(\"Could not find a FlowElement for activityId \" + execution.getCurrentActivityId() + \" in \" + execution);\n        }\n        return flowElement;\n    }\n\n    /**\n     * Returns whether or not the provided execution is being use for executing an {@link ExecutionListener}.\n     */\n    public static boolean isExecutingExecutionListener(DelegateExecution execution) {\n        return execution.getCurrentFlowableListener() != null;\n    }\n\n    /**\n     * Returns for the activityId of the passed {@link DelegateExecution} the {@link Map} of {@link ExtensionElement} instances. These represent the extension elements defined in the BPMN 2.0 XML as\n     * part of that particular activity.\n     * \n     * If the execution is currently being used for executing an {@link ExecutionListener}, the extension elements of the listener will be used. Use the\n     * {@link #getFlowElementExtensionElements(DelegateExecution)} or {@link #getListenerExtensionElements(DelegateExecution)} instead to specifically get the extension elements of either the flow\n     * element or the listener.","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/DelegateHelper.java#L66-L102","documentation":"DelegateHelper.getFlowElement resolves the BpmnModel FlowElement matching the execution's current activityId. When the model contains no element for that activityId, Flowable throws this FlowableException rather than returning null, since delegate code cannot proceed without the element definition.","triggerScenarios":"Calling DelegateHelper.getFlowElement(execution) (directly or via flowElement()/getFlowElementExtensionElements()) when execution.getCurrentActivityId() does not exist in the process definition's BpmnModel — e.g. a delegate/listener executing for an activity not present in the deployed model, or a stale/mismatched process definition version.","commonSituations":"Dynamic model modification or incomplete BpmnModel deployment; executing a delegate in a context (like an async job or migration) where the cached model differs from the deployed one; typo'd or programmatically-injected activity ids; using DelegateHelper outside an actual flow-element execution context.","solutions":["Verify the activityId exists in the deployed process definition's BpmnModel (inspect the BPMN XML / model)","Check that the execution's process definition version matches the model you expect; redeploy the correct BPMN resource","Ensure DelegateHelper.getFlowElement is only invoked from code running inside a real flow-element execution (execution listener, task listener, delegate on an activity)","Guard by catching FlowableException and falling back to execution.getCurrentFlowElement() if available"],"exampleFix":"// before\nFlowElement el = DelegateHelper.getFlowElement(execution);\n// after\nFlowElement el = execution.getCurrentFlowElement();\nif (el == null) {\n    el = DelegateHelper.getFlowElement(execution); // only when safe\n}","handlingStrategy":"try-catch","validationCode":"boolean ok = execution.getCurrentActivityId() != null && execution.getCurrentFlowElement() != null;","typeGuard":"function hasFlowElement(exec) { return exec.getCurrentFlowElement && exec.getCurrentFlowElement() != null; }","tryCatchPattern":"try { FlowElement el = DelegateHelper.getFlowElement(execution); ... } catch (FlowableException e) { logger.warn(\"No FlowElement for activityId \" + execution.getCurrentActivityId()); }","preventionTips":["Prefer execution.getCurrentFlowElement() over DelegateHelper.getFlowElement when available","Only call DelegateHelper inside activity-scoped delegate/listener code","Validate deployed BPMN XML contains all referenced activity ids","Keep process definitions and deployments in sync across cluster nodes"],"tags":["bpmn","flowable","process-model"],"backgroundTag":"entity-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}