Activiti/Activiti · error · ActivitiException
Could not find a FlowElement for activityId
Error message
Could not find a FlowElement for activityId ${currentActivityId} What it means
DelegateHelper.getFlowElement(execution) resolves the FlowElement for the execution's currentActivityId from the process BpmnModel; when the model lookup returns null it throws ActivitiException. This means the execution claims to sit on an activity id that does not exist in the definition's model.
Solutions
- Only call getFlowElement from contexts where the execution is positioned on a concrete activity (start of a task listener, ExecutionListener EVENTNAME_START on the activity).
- Log execution.getCurrentActivityId() and execution.getProcessDefinitionId() and confirm the id exists in that deployment's BPMN XML.
- Handle legacy instances explicitly: guard with bpmnModel.getFlowElement(id) == null and skip/fallback instead of throwing.
Example fix
// before
FlowElement el = DelegateHelper.getFlowElement(execution); // throws when id missing
// after
BpmnModel model = DelegateHelper.getBpmnModel(execution);
FlowElement el = model.getFlowElement(execution.getCurrentActivityId());
if (el == null) {
logger.warn("No flow element for " + execution.getCurrentActivityId());
return;
} Defensive patterns
Strategy: try-catch
Validate before calling
BpmnModel model = DelegateHelper.getBpmnModel(execution);
if (execution.getCurrentActivityId() == null || model.getFlowElement(execution.getCurrentActivityId()) == null) {
return; // execution not positioned on a resolvable activity
} Type guard
boolean hasCurrentFlowElement(DelegateExecution e) {
return e.getCurrentActivityId() != null
&& DelegateHelper.getBpmnModel(e).getFlowElement(e.getCurrentActivityId()) != null;
} Try / catch
try {
FlowElement el = DelegateHelper.getFlowElement(execution);
} catch (ActivitiException e) {
logger.warn("No FlowElement for activity {} on definition {}",
execution.getCurrentActivityId(), execution.getProcessDefinitionId());
} Prevention
- Call getFlowElement only from activity-scoped listeners (start events, task create)
- Watch for old instances after redeploying processes with renamed ids
- Log activityId + processDefinitionId when handling model lookups
When it happens
Trigger: Calling getFlowElement while the execution is not positioned on an activity (currentActivityId null or stale); the activity id belongs to a different process definition (mismatched model lookup via execution.getProcessDefinitionId()); dynamic/modified process instances after a redeployment.
Common situations: Task/execution listeners attached to a process that was redeployed with renamed ids while old instances still run; calling the helper inside a listener where the execution is between activities (e.g. on sequence-flow take or end listeners); call-activity child executions resolved against the parent's model.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Cannot start process instance. Process model
- Cannot execute operation because process definition
- Cannot find process definition for id '
- Cannot find process definition for key '
- Cannot find process definition with id
AI-assisted analysis of Activiti/Activiti@56435b1a97 (2026-09-09).
Data as JSON: /api/errors/9617d1c01e507b65.
Report an issue: GitHub.
Appendix: source
Thrown at activiti-core/activiti-engine/src/main/java/org/activiti/engine/delegate/DelegateHelper.java:87
/**
* Returns the {@link BpmnModel} matching the process definition bpmn model
* for the process definition of the passed {@link DelegateExecution}.
*/
public static BpmnModel getBpmnModel(DelegateExecution execution) {
if (execution == null) {
throw new ActivitiException("Null execution passed");
}
return ProcessDefinitionUtil.getBpmnModel(execution.getProcessDefinitionId());
}
/**
* Returns the current {@link FlowElement} where the {@link DelegateExecution} is currently at.
*/
public static FlowElement getFlowElement(DelegateExecution execution) {
BpmnModel bpmnModel = getBpmnModel(execution);
FlowElement flowElement = bpmnModel.getFlowElement(execution.getCurrentActivityId());
if (flowElement == null) {
throw new ActivitiException(
"Could not find a FlowElement for activityId " + execution.getCurrentActivityId()
);
}
return flowElement;
}
/**
* Returns whether or not the provided execution is being use for executing an {@link ExecutionListener}.
*/
public static boolean isExecutingExecutionListener(DelegateExecution execution) {
return execution.getCurrentActivitiListener() != null;
}
/**
* 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 part of that particular
* activity.View on GitHub (pinned to 56435b1a97)