flowable/flowable-engine · error · FlowableException
batch entity not found for id
Error message
batch entity not found for id
What it means
DeleteBatchCmd loads the batch entity via the BatchService; if no batch exists for the given batchId it throws a plain FlowableException. Batches (e.g. async migration/delete jobs) must exist before they can be deleted.
Solutions
- Check existence first: processEngineConfiguration.getBatchServiceConfiguration().getBatchService().getBatch(batchId) (or keep your own registry) before deleting.
- Treat deletion as idempotent: catch the FlowableException and skip if the batch is already gone.
- Verify you are connected to the same database where the batch was created.
Example fix
// before
managementService.deleteBatch(batchId);
// after
Batch batch = ... getBatch(batchId);
if (batch != null) {
managementService.deleteBatch(batchId);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Batch lookup requires engine internals; check your own registry or query managementService tables before deleting
Try / catch
try {
managementService.deleteBatch(batchId);
} catch (FlowableException e) {
if (e.getMessage().startsWith("batch entity not found")) { log.info("Batch {} already gone", batchId); } else { throw e; }
} Prevention
- Make batch deletion idempotent in retry/dedup logic
- Track created batch ids and mark them deleted in your own store
- Confirm engine/database affinity before deleting batches
When it happens
Trigger: Calling ManagementService.deleteBatch(batchId) with an id that has no ACT_RU_BATCH row — already deleted, wrong id, or id from a different engine configuration/database.
Common situations: Double deletion of the same batch in retry logic; batch expired and was purged automatically; referencing a batch id captured before a database reset.
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
- Could not find a batch with id
- batch has to be provided
- Batch with id ' ' does not have a batch document.
- batchId is null
- batchSearchKey is null
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/401056da31c493fe.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/DeleteBatchCmd.java:37
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil;
public class DeleteBatchCmd implements Command<Void> {
protected String batchId;
public DeleteBatchCmd(String batchId) {
this.batchId = batchId;
}
@Override
public Void execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
BatchService batchService = processEngineConfiguration.getBatchServiceConfiguration().getBatchService();
Batch batch = batchService.getBatch(batchId);
if (batch == null) {
throw new FlowableException("batch entity not found for id " + batchId);
}
batchService.deleteBatch(batchId);
return null;
}
}
View on GitHub (pinned to d6d39ce1c6)