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

Thrown by removeDeployment when no EventDeploymentEntity with the given deploymentId exists in the database. Flowable raises FlowableObjectNotFoundException so callers deleting deployments learn the id is unknown rather than silently doing nothing.

Solutions

  1. Check existence first with eventRepositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult() and skip if null.
  2. Verify you are connected to the database/environment where the deployment was made.
  3. Make deletion idempotent: wrap in an existence check or catch FlowableObjectNotFoundException.
  4. If the deployment should exist, investigate cascade deletes or manual DB cleanup that removed it.

Example fix

// before
eventRepositoryService.deleteDeployment(deploymentId); // throws if missing
// after
if (eventRepositoryService.createDeploymentQuery().deploymentId(deploymentId).count() > 0) {
    eventRepositoryService.deleteDeployment(deploymentId);
}
Defensive patterns

Strategy: validation

Validate before calling

boolean exists = eventRepositoryService.createDeploymentQuery().deploymentId(deploymentId).count() > 0;
if (!exists) return; // nothing to delete

Try / catch

try {
    eventRepositoryService.deleteDeployment(deploymentId);
} catch (FlowableObjectNotFoundException e) {
    // already gone; treat as success for idempotent cleanup
}

Prevention

When it happens

Trigger: Calling removeDeployment(deploymentId) with an id that was already deleted, never existed in this database, or belongs to another environment/tenant database.

Common situations: Running cleanup scripts against the wrong schema; double-invocation of delete logic; ids copied from another environment; deleting after a cascade already removed the deployment.

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


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

Appendix: source

Thrown at modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/persistence/deploy/EventDeploymentManager.java:227

            for (EventResourceEntity resource : resources) {
                deployment.addResource(resource);
            }

            deployment.setNew(false);
            deploy(deployment);
            cachedChannelDefinition = channelDefinitionCache.get(channelDefinitionId);

            if (cachedChannelDefinition == null) {
                throw new FlowableException("deployment '" + deploymentId + "' didn't put channel definition '" + channelDefinitionId + "' in the cache");
            }
        }
        return cachedChannelDefinition;
    }

    public void removeDeployment(String deploymentId) {
        EventDeploymentEntity deployment = deploymentEntityManager.findById(deploymentId);
        if (deployment == null) {
            throw new FlowableObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.");
        }

        // Remove any event and channel definition from the cache
        List<EventDefinition> eventDefinitions = new EventDefinitionQueryImpl().deploymentId(deploymentId).list();
        List<ChannelDefinition> channelDefinitions = new ChannelDefinitionQueryImpl().deploymentId(deploymentId).list();

        // Delete data
        deploymentEntityManager.deleteDeployment(deploymentId);

        FlowableEventDispatcher eventDispatcher = engineConfig.getEventDispatcher();

        for (EventDefinition eventDefinition : eventDefinitions) {
            eventDefinitionCache.remove(eventDefinition.getId());
            if (eventDispatcher != null && eventDispatcher.isEnabled()) {
                eventDispatcher.dispatchEvent(new FlowableEntityEventImpl(eventDefinition, FlowableEngineEventType.DEFINITION_UNDEPLOYED),
                        EngineConfigurationConstants.KEY_EVENT_REGISTRY_CONFIG);
            }
        }

View on GitHub (pinned to d6d39ce1c6)