flowable/flowable-engine · error · FlowableException

The requested activity with id ${activityId} can not be enab

Error message

The requested activity with id ${activityId} can not be enabled in ${execution}

What it means

After scanning the ad-hoc subprocess flow elements, if no FlowNode with the requested activityId (having incoming flows) is found, execute() throws FlowableException: the requested activity cannot be enabled in this ad-hoc subprocess.

Source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ExecuteActivityForAdhocSubProcessCmd.java:72

        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;
                }
            }
        }

        if (foundNode == null) {
            throw new FlowableException("The requested activity with id " + activityId + " can not be enabled in " + execution);
        }

        ExecutionEntity activityExecution = CommandContextUtil.getExecutionEntityManager().createChildExecution(execution);
        activityExecution.setCurrentFlowElement(foundNode);
        CommandContextUtil.getAgenda().planContinueProcessOperation(activityExecution);

        return activityExecution;
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Verify the activityId exists as a FlowNode inside the adhocSubProcess element in the deployed BPMN
  2. Ensure the target node has at least one incoming sequence flow (adhoc activity must be enterable)
  3. Re-fetch the model from the deployment (repositoryService.getBpmnModel) instead of a stale local copy

Example fix

// before
managementService.executeCommand(new ExecuteActivityForAdhocSubProcessCmd(execId, "taskA"));
// after
BpmnModel model = repositoryService.getBpmnModel(processDefinitionId);
AdhocSubProcess adhoc = (AdhocSubProcess) model.getMainProcess().getFlowElement("adhoc1");
if (adhoc.getFlowElement("taskA") != null) {
    managementService.executeCommand(new ExecuteActivityForAdhocSubProcessCmd(execId, "taskA"));
}
Defensive patterns

Strategy: validation

Validate before calling

FlowElement el = bpmnModel.getMainProcess().getFlowElement(activityId);
if (!(el instanceof FlowNode) || ((FlowNode) el).getIncomingFlows().isEmpty()) throw new IllegalArgumentException("activity not enabled-able: " + activityId);

Type guard

boolean isEnabledAdhocActivity(AdhocSubProcess adhoc, String id) { return adhoc.getFlowElement(id) instanceof FlowNode fn && !fn.getIncomingFlows().isEmpty(); }

Try / catch

try { ... } catch (FlowableException e) { if (e.getMessage().contains("can not be enabled")) { /* validate activityId against deployed model */ } else throw e; }

Prevention

When it happens

Trigger: Calling ExecuteActivityForAdhocSubProcessCmd with an activityId that does not exist inside the ad-hoc subprocess, or that is not a FlowNode / has no incoming sequence flows.

Common situations: Typos or renamed activity ids after model changes; passing an id of an element outside the ad-hoc subprocess; targeting a start-event-only element without incoming flows.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/b7f4f99ed03e0ad6. Report an issue: GitHub.