flowable/flowable-engine · error · FlowableCdiException
Cannot associate execution by id: no execution with id '
Error message
Cannot associate execution by id: no execution with id '
What it means
associateExecutionById validates the execution id with an ExecutionQuery and throws FlowableCdiException when no execution with that id exists, refusing to associate the CDI conversation with a nonexistent execution. Called internally by startTask, setExecution, and setExecutionId.
Source
Thrown at modules/flowable-cdi/src/main/java/org/flowable/cdi/BusinessProcess.java:274
Map<String, Object> cachedVariables = getAndClearCachedVariables();
cachedVariables.putAll(variables);
ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(definition.getId(), cachedVariables);
if (!instance.isEnded()) {
setExecution(instance);
}
return instance;
}
/**
* Associate with the provided execution. This starts a unit of work.
*
* @param executionId the id of the execution to associate with.
* @throws FlowableCdiException if no such execution exists
*/
public void associateExecutionById(String executionId) {
Execution execution = processEngine.getRuntimeService().createExecutionQuery().executionId(executionId).singleResult();
if (execution == null) {
throw new FlowableCdiException("Cannot associate execution by id: no execution with id '" + executionId + "' found.");
}
associationManager.setExecution(execution);
}
/**
* returns true if an {@link Execution} is associated.
*
* @see #associateExecutionById(String)
*/
public boolean isAssociated() {
return associationManager.getExecutionId() != null;
}
/**
* Signals the current execution, see {@link RuntimeService#trigger(String)}
* <p>
* Ends the current unit of work (flushes changes to process variables set using {@link #setVariable(String, Object)} or made on {@link BusinessProcessScoped @BusinessProcessScoped} beans).
*View on GitHub (pinned to d6d39ce1c6)
Solutions
- Query the execution first (runtimeService.createExecutionQuery().executionId(id).singleResult()) and handle null before associating.
- Ensure the process instance is still running — completed/historic instances cannot be associated.
- Fix id storage/retrieval so the exact process instance id is passed.
Example fix
// before
businessProcess.associateExecutionById(id); // throws if gone
// after
Execution e = runtimeService.createExecutionQuery().executionId(id).singleResult();
if (e != null) {
businessProcess.associateExecutionById(id);
} Defensive patterns
Strategy: validation
Validate before calling
Execution e = runtimeService.createExecutionQuery().executionId(executionId).singleResult();
if (e == null) {
// skip association / recover
} Type guard
boolean executionExists(String id) {
return runtimeService.createExecutionQuery().executionId(id).count() > 0;
} Try / catch
try {
businessProcess.associateExecutionById(id);
} catch (FlowableCdiException e) {
// execution gone: reset conversation state or notify user
} Prevention
- Only associate ids of running process instances
- Re-associate when restoring CDI conversations
- Do not cache execution ids beyond the process lifetime
When it happens
Trigger: Passing a stale, completed, or mistyped execution/process-instance id to businessProcess.associateExecutionById(...) or businessProcess.setExecutionId(...) (the latter indirectly).
Common situations: Resuming a conversation whose process instance has already ended and been removed; storing the id as a String in a form/session and it changed or got truncated; calling before the process instance actually started.
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
- No process definition found for name:
- Cannot resume task with id '
- No execution associated. Call businessProcess.associateExecu
- Cannot find process instance with id
- No execution found for id ''
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/190b60845198ba20.
Report an issue: GitHub.