flowable/flowable-engine · error · FlowableObjectNotFoundException

Could not find a deployment with id

Error message

Could not find a deployment with id '<deploymentId>'.

What it means

removeDeployment(deploymentId, cascade) first loads the deployment entity by id. If no deployment with that id exists, it throws FlowableObjectNotFoundException for CmmnDeploymentEntity before any undeploy logic runs. Idempotent deletion is not built in — callers must handle the not-found case.

Solutions

  1. Query first: cmmnRepositoryService.createDeploymentQuery().deploymentId(id).singleResult() and skip deletion when null
  2. Wrap the delete in try-catch for FlowableObjectNotFoundException and treat it as already deleted
  3. Verify the id came from the CMMN repository, not the BPMN/process repository

Example fix

// before
cmmnRepositoryService.deleteDeployment(deploymentId); // throws if missing
// after
if (cmmnRepositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult() != null) {
    cmmnRepositoryService.deleteDeployment(deploymentId, true);
}
Defensive patterns

Strategy: try-catch

Validate before calling

boolean exists = repositoryService.createDeploymentQuery().deploymentId(deploymentId).count() > 0;

Try / catch

try { repositoryService.deleteDeployment(id, cascade); } catch (FlowableObjectNotFoundException e) { log.info("Deployment {} already gone", id); }

Prevention

When it happens

Trigger: Calling CmmnRepositoryService.deleteDeployment(id) with a wrong, already-deleted, or foreign-engine deployment id; deleting twice after a first successful delete; using a process deployment id against the CMMN engine.

Common situations: Scripts re-running undeploy steps after a failure mid-way; typo'd or hard-coded ids; CI cleanup jobs racing each other to delete the same deployment.

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/4b2cd94f35e3df99. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/deployer/CmmnDeploymentManager.java:131

            deployment.setNew(false);
            deploy(deployment, null);
            cachedCaseDefinition = deployment.getCaseDefinitionCacheEntry(caseDefinitionId);

            if (cachedCaseDefinition == null) {
                throw new FlowableException("deployment '" + deploymentId + "' didn't put case definition '" + caseDefinitionId + "' in the cache");
            }
        }
        return cachedCaseDefinition;
    }
    
    public void removeDeployment(String deploymentId) {
        removeDeployment(deploymentId, true);
    }
    
    public void removeDeployment(String deploymentId, boolean cascade) {
        CmmnDeploymentEntity deployment = deploymentEntityManager.findById(deploymentId);
        if (deployment == null) {
            throw new FlowableObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", CmmnDeploymentEntity.class);
        }
        
        List<EngineDeployer> engineUnDeployers = new ArrayList<>(deployers);
        engineUnDeployers.sort(Comparator.comparingInt(EngineDeployer::getUndeployOrder));

        for (EngineDeployer deployer : engineUnDeployers) {
            deployer.undeploy(deployment, cascade);
        }

        List<CaseDefinition> caseDefinitions = new CaseDefinitionQueryImpl().deploymentId(deploymentId).list();

        deploymentEntityManager.deleteDeploymentAndRelatedData(deploymentId, cascade);

        FlowableEventDispatcher eventDispatcher = cmmnEngineConfiguration.getEventDispatcher();
        for (CaseDefinition caseDefinition : caseDefinitions) {
            caseDefinitionCache.remove(caseDefinition.getId());
            if (eventDispatcher != null && eventDispatcher.isEnabled()) {
                eventDispatcher.dispatchEvent(new FlowableEntityEventImpl(caseDefinition, FlowableEngineEventType.DEFINITION_UNDEPLOYED),

View on GitHub (pinned to d6d39ce1c6)