flowable/flowable-engine · error · FlowableException
The current flow element of the requested ${execution} is no
Error message
The current flow element of the requested ${execution} is not an ad-hoc sub process What it means
This command only works when the execution's current flow element is an AdhocSubProcess. If the execution points at any other element (or none), execute() throws FlowableException because ad-hoc activity execution is only valid inside an ad-hoc subprocess.
Source
Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ExecuteActivityForAdhocSubProcessCmd.java:51
private static final long serialVersionUID = 1L;
protected String executionId;
protected String activityId;
public ExecuteActivityForAdhocSubProcessCmd(String executionId, String activityId) {
this.executionId = executionId;
this.activityId = activityId;
}
@Override
public Execution execute(CommandContext commandContext) {
ExecutionEntity execution = CommandContextUtil.getExecutionEntityManager(commandContext).findById(executionId);
if (execution == null) {
throw new FlowableObjectNotFoundException("No execution found for id '" + executionId + "'", ExecutionEntity.class);
}
if (!(execution.getCurrentFlowElement() instanceof AdhocSubProcess adhocSubProcess)) {
throw new FlowableException("The current flow element of the requested " + execution + " is not an ad-hoc sub process");
}
FlowNode foundNode = null;
// if sequential ordering, only one child execution can be active
if (adhocSubProcess.hasSequentialOrdering()) {
if (execution.getExecutions().size() > 0) {
throw new FlowableException("Sequential ad-hoc sub process in " + execution + " already has an active execution");
}
}
for (FlowElement flowElement : adhocSubProcess.getFlowElements()) {
if (activityId.equals(flowElement.getId()) && flowElement instanceof FlowNode flowNode) {
if (flowNode.getIncomingFlows().size() == 0) {
foundNode = flowNode;
}
}
}View on GitHub (pinned to d6d39ce1c6)
Solutions
- Locate the child execution inside the ad-hoc subprocess: runtimeService.createExecutionQuery().processInstanceId(pid).activityId(adhocSubProcessId)
- Verify the process model actually contains an adhocSubProcess element and the execution is currently inside it
- Redeploy/update the BPMN if the model was changed and executions are stuck on old definitions
Example fix
// before
managementService.executeCommand(new ExecuteActivityForAdhocSubProcessCmd(processInstanceId, "callActivity1"));
// after
Execution adhocExec = runtimeService.createExecutionQuery()
.processInstanceId(processInstanceId).activityId("adhocSubProcess1").singleResult();
managementService.executeCommand(new ExecuteActivityForAdhocSubProcessCmd(adhocExec.getId(), "callActivity1")); Defensive patterns
Strategy: validation
Validate before calling
Execution adhocExec = runtimeService.createExecutionQuery().processInstanceId(pid).activityId(adhocSubProcessId).singleResult();
if (adhocExec == null) throw new IllegalArgumentException("execution not inside ad-hoc subprocess"); Type guard
boolean isAdhocExecution(Execution e) { return ((ExecutionEntity) e).getCurrentFlowElement() instanceof AdhocSubProcess; } Try / catch
try { ... } catch (FlowableException e) { if (e.getMessage().contains("not an ad-hoc sub process")) { /* locate correct child execution */ } else throw e; } Prevention
- Model inspection: confirm the element under the execution is an adhocSubProcess
- Query child executions by activityId instead of reusing the parent id
- Re-inspect after process definition version changes
When it happens
Trigger: Invoking ExecuteActivityForAdhocSubProcessCmd with an execution whose currentFlowElement is a regular subprocess, user task, process definition, or is null.
Common situations: Passing the parent process instance execution instead of the execution running inside the ad-hoc subprocess; process definition changed after deployment so the element under the execution is no longer ad-hoc.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- The current flow element of the requested ${execution} is no
- No execution found for id '${executionId}'
- Sequential ad-hoc sub process in ${execution} already has an
- The requested activity with id ${activityId} can not be enab
- baseUrl can not be null
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/6d752e6e018db735.
Report an issue: GitHub.