flowable/flowable-engine · error · FlowableException
Invalid targetElementId
Error message
Invalid targetElementId '${targetElementId}': no element found for this id n process definition '${processDefinitionId}' What it means
Same validation as the source-side error but for the target element: isReachable resolves targetElementId, resolving through SequenceFlow to its target node if needed. If no element (or no sequence flow target) exists for targetElementId in the given process definition, the traversal cannot be performed and this FlowableException is thrown.
Solutions
- Verify the targetElementId exists in the deployed process model and fix the id.
- If the id points at a SequenceFlow, ensure that flow has a valid target flow element in the BPMN XML.
- Confirm processDefinitionId matches the definition version containing that target element.
- Guard the call by checking model.getFlowElement(targetElementId) != null first.
Example fix
// before
boolean ok = isReachable(processDefinitionId, "taskA", "taskZ");
// after
BpmnModel model = repositoryService.getBpmnModel(processDefinitionId);
FlowElement target = model.getFlowElement("endEvent");
if (target != null) {
boolean ok = isReachable(processDefinitionId, "taskA", "endEvent");
} Defensive patterns
Strategy: validation
Validate before calling
BpmnModel model = repositoryService.getBpmnModel(processDefinitionId);
FlowElement target = model.getFlowElement(targetElementId);
if (target == null || (target instanceof SequenceFlow && ((SequenceFlow) target).getTargetFlowElement() == null)) {
throw new IllegalArgumentException("targetElementId " + targetElementId + " invalid");
} Prevention
- Ensure sequence flows have valid targets in BPMN XML (schema validation on deploy)
- Match target ids to the exact definition version
- Validate ids against the model before graph queries
When it happens
Trigger: Calling public isReachable(processDefinitionId, sourceElementId, targetElementId) where targetElementId is absent from the process model, or it names a SequenceFlow whose getTargetFlowElement() resolves to null (e.g. a dangling sequence flow with no target).
Common situations: Target id typo; referencing a target from a different definition version; malformed BPMN with a sequence flow lacking a valid target after model edits; using ids from an externally edited diagram that no longer match the deployed model.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Invalid sourceElementId
- activity ' ' has duplicate transition
- Could not find a FlowElement for activityId
- Could not find cancel boundary event for cancel end event
- Default sequence flow
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/ee8430d44942fb4a.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/ExecutionGraphUtil.java:65
if (sourceFlowElement instanceof FlowNode) {
sourceElement = (FlowNode) sourceFlowElement;
} else if (sourceFlowElement instanceof SequenceFlow) {
sourceElement = (FlowNode) ((SequenceFlow) sourceFlowElement).getTargetFlowElement();
}
FlowElement targetFlowElement = process.getFlowElement(targetElementId, true);
FlowNode targetElement = null;
if (targetFlowElement instanceof FlowNode) {
targetElement = (FlowNode) targetFlowElement;
} else if (targetFlowElement instanceof SequenceFlow) {
targetElement = (FlowNode) ((SequenceFlow) targetFlowElement).getTargetFlowElement();
}
if (sourceElement == null) {
throw new FlowableException("Invalid sourceElementId '" + sourceElementId + "': no element found for this id n process definition '" + processDefinitionId + "'");
}
if (targetElement == null) {
throw new FlowableException("Invalid targetElementId '" + targetElementId + "': no element found for this id n process definition '" + processDefinitionId + "'");
}
Set<String> visitedElements = new HashSet<>();
return isReachable(process, sourceElement, targetElement, visitedElements);
}
public static boolean isReachable(Process process, FlowNode sourceElement, FlowNode targetElement, Set<String> visitedElements) {
// Special case: start events in an event subprocess might exist as an execution and are most likely be able to reach the target
// when the target is in the event subprocess, but should be ignored as they are not 'real' runtime executions (but rather waiting for a trigger)
if (sourceElement instanceof StartEvent && isInEventSubprocess(sourceElement)) {
return false;
}
// No outgoing seq flow: could be the end of eg . the process or an embedded subprocess
if (sourceElement.getOutgoingFlows().size() == 0) {
visitedElements.add(sourceElement.getId());
View on GitHub (pinned to d6d39ce1c6)