flowable/flowable-engine · error · ActivitiObjectNotFoundException

Could not find a deployment with id

Error message

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

What it means

ActivitiObjectNotFoundException thrown by DeploymentManager.removeDeployment when the deployment id passed to RepositoryService.deleteDeployment does not exist. The engine looks up the DeploymentEntity first; null triggers this error before any cascade deletion begins, so nothing is removed.

Solutions

  1. Check existence first: repositoryService.createDeploymentQuery().deploymentId(id).singleResult() != null
  2. Skip deletion (or log-and-continue) when the deployment is already absent — the end state (not deployed) is already achieved
  3. List valid deployments via repositoryService.createDeploymentQuery().list() to find the correct id
  4. Verify the delete runs against the same database the deployment was made in

Example fix

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

Strategy: validation

Validate before calling

if (repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult() == null) {
    return; // already deleted — treat delete as idempotent
}

Try / catch

try {
    repositoryService.deleteDeployment(deploymentId, true);
} catch (ActivitiObjectNotFoundException e) {
    log.info("Deployment {} already removed", deploymentId);
}

Prevention

When it happens

Trigger: Calling repositoryService.deleteDeployment(deploymentId) or deleteDeployment(deploymentId, cascade) with an id that was never created, already deleted, or belongs to another database/tenant.

Common situations: Deleting the same deployment twice, ids from a different environment's database, truncated ids from logs, or cleanup scripts running against the wrong schema.

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


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

Appendix: source

Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/persistence/deploy/DeploymentManager.java:207

            deployment.setNew(false);
            deploy(deployment, null);
            cachedProcessDefinition = processDefinitionCache.get(processDefinitionId);

            if (cachedProcessDefinition == null) {
                throw new ActivitiException("deployment '" + deploymentId + "' didn't put process definition '" + processDefinitionId + "' in the cache");
            }
        }
        return cachedProcessDefinition;
    }

    public void removeDeployment(String deploymentId, boolean cascade) {
        DeploymentEntityManager deploymentEntityManager = Context
                .getCommandContext()
                .getDeploymentEntityManager();

        DeploymentEntity deployment = deploymentEntityManager.findDeploymentById(deploymentId);
        if (deployment == null) {
            throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", DeploymentEntity.class);
        }

        // Remove any process definition from the cache
        List<ProcessDefinition> processDefinitions = new ProcessDefinitionQueryImpl(Context.getCommandContext())
                .deploymentId(deploymentId)
                .list();

        FlowableEventDispatcher eventDispatcher = Context.getProcessEngineConfiguration().getEventDispatcher();

        for (ProcessDefinition processDefinition : processDefinitions) {

            // Since all process definitions are deleted by a single query, we should dispatch the events in this loop
            if (eventDispatcher.isEnabled()) {
                eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityEvent(
                        FlowableEngineEventType.ENTITY_DELETED, processDefinition),
                        EngineConfigurationConstants.KEY_PROCESS_ENGINE_CONFIG);
            }
        }

View on GitHub (pinned to d6d39ce1c6)