flowable/flowable-engine · error · FlowableObjectNotFoundException
No batch found for id ${batchId}
Error message
No batch found for id ${batchId} What it means
GetBatchDocumentCmd fetches a batch via the batch service; when getBatch(batchId) returns null it throws FlowableObjectNotFoundException. It returns the batch's document JSON for this engine configuration key.
Source
Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetBatchDocumentCmd.java:35
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil;
public class GetBatchDocumentCmd implements Command<String> {
protected String batchId;
public GetBatchDocumentCmd(String batchId) {
this.batchId = batchId;
}
@Override
public String execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
Batch batch = processEngineConfiguration.getBatchServiceConfiguration().getBatchService().getBatch(batchId);
if (batch == null) {
throw new FlowableObjectNotFoundException("No batch found for id " + batchId);
}
return batch.getBatchDocumentJson(processEngineConfiguration.getEngineCfgKey());
}
}
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Check the batch exists first via the batch service query before fetching its document
- Verify batch cleanup/rotation jobs didn't delete the batch
- Confirm the batchId string is complete and from the same engine configuration
Example fix
// before
String doc = managementService.executeCommand(new GetBatchDocumentCmd(batchId));
// after
Batch batch = batchService.createBatchQuery().batchId(batchId).singleResult();
String doc = batch != null
? managementService.executeCommand(new GetBatchDocumentCmd(batchId)) : null; Defensive patterns
Strategy: try-catch
Validate before calling
Batch batch = batchService.createBatchQuery().batchId(batchId).singleResult();
if (batch == null) throw new IllegalArgumentException("unknown batchId: " + batchId); Try / catch
try { ... } catch (FlowableObjectNotFoundException e) { if (e.getMessage().startsWith("No batch found")) { /* treat as expired batch; refresh from batch query */ } else throw e; } Prevention
- Treat batch ids as ephemeral; re-query before document fetch
- Account for batch cleanup jobs removing old batches
- Validate batchId source (same engine/config key) before use
When it happens
Trigger: Querying a batch id that does not exist, belongs to another engine config key, or whose batch rows were purged by cleanup jobs.
Common situations: Monitoring dashboards holding batch ids after batch part cleanup ran; typo in batch id; pointing at a database where the batch table was truncated.
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
- No batch part found for id ${batchPartId}
- No batch part found for id ${batchPartId}
- No batch found for id ${batchId}
- Batch with id '${batchId}' does not have a batch document.
- Could not find a batch with id '${batchId}'.
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/3e929fb1354f16f5.
Report an issue: GitHub.