flowable/flowable-engine · error · FlowableException

batch entity not found for id

Error message

batch entity not found for id 

What it means

DeleteBatchCmd delegates to the BatchService to load the batch entity for the given batchId; if the service returns null, the command throws a plain FlowableException. Batches (e.g. for bulk deletions/migrations) may already have been deleted, cleaned up by the async history/job executor, or the id may be wrong.

Solutions

  1. Check batch existence first via batchService/query APIs (e.g. managementService.findBatch(...) or batch query) and skip deletion when absent
  2. Ensure the delete is idempotent: catch FlowableException with this message and treat it as success
  3. Verify the batchId comes from the same engine configuration/database

Example fix

// before
managementService.deleteBatch(batchId);
// after
Batch batch = managementService.findBatch(batchId);
if (batch != null) {
    managementService.deleteBatch(batchId);
}
Defensive patterns

Strategy: try-catch

Validate before calling

Batch batch = managementService.findBatch(batchId);
boolean exists = batch != null;

Try / catch

try { managementService.deleteBatch(batchId); }
catch (FlowableException e) { if (e.getMessage() != null && e.getMessage().startsWith("batch entity not found")) { log.info("batch already gone: {}", batchId); } else throw e; }

Prevention

When it happens

Trigger: Calling CmmnManagementService.deleteBatch(batchId) (or the deleteBatchCmd) with an id that never existed, was already deleted, or whose batch rows were purged.

Common situations: Double-invocation of a delete routine; referencing a batch id from a different engine/database; retention/cleanup jobs removing the batch before the explicit delete runs.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/DeleteBatchCmd.java:37

import org.flowable.common.engine.api.FlowableException;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;

public class DeleteBatchCmd implements Command<Void> {
    
    protected String batchId;
    
    public DeleteBatchCmd(String batchId) {
        this.batchId = batchId;
    }
    
    @Override
    public Void execute(CommandContext commandContext) {
        CmmnEngineConfiguration engineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
        BatchService batchService = engineConfiguration.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)