flowable/flowable-engine · error · FlowableObjectNotFoundException

Could not find deployment with id ${deploymentId}

Error message

Could not find deployment with id ${deploymentId}

What it means

SetDeploymentTenantIdCmd throws FlowableObjectNotFoundException when the event deployment with the given id does not exist in the event registry. It is thrown inside the command's execute() right after findById(deploymentId) returns null, before the tenant id change is applied to the deployment and its event definitions.

Source

Thrown at modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/cmd/SetDeploymentTenantIdCmd.java:53

    protected String deploymentId;
    protected String newTenantId;

    public SetDeploymentTenantIdCmd(String deploymentId, String newTenantId) {
        this.deploymentId = deploymentId;
        this.newTenantId = newTenantId;
    }

    @Override
    public Void execute(CommandContext commandContext) {
        if (deploymentId == null) {
            throw new FlowableIllegalArgumentException("deploymentId is null");
        }

        // Update all entities

        EventDeploymentEntity deployment = CommandContextUtil.getDeploymentEntityManager(commandContext).findById(deploymentId);
        if (deployment == null) {
            throw new FlowableObjectNotFoundException("Could not find deployment with id " + deploymentId);
        }

        deployment.setTenantId(newTenantId);

        CommandContextUtil.getEventDefinitionEntityManager(commandContext).updateEventDefinitionTenantIdForDeployment(deploymentId, newTenantId);

        // Doing event definitions in memory, cause we need to clear the event definition cache
        List<EventDefinition> eventDefinitions = new EventDefinitionQueryImpl().deploymentId(deploymentId).list();
        for (EventDefinition eventDefinition : eventDefinitions) {
            CommandContextUtil.getEventRegistryConfiguration().getEventDefinitionCache().remove(eventDefinition.getId());
        }

        CommandContextUtil.getDeploymentEntityManager(commandContext).update(deployment);

        return null;

    }

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Query the deployment first (eventRepositoryService.createDeploymentQuery().deploymentId(id)) and verify it exists before setting the tenant id.
  2. Print/correct the deploymentId - fetch actual ids via eventRepositoryService.createDeploymentQuery().list().
  3. Verify you are connected to the same event registry engine/database where the deployment was made.

Example fix

// before
eventRepositoryService.setDeploymentTenantId("my-deployment-id", "tenant-1");
// after
EventDeployment d = eventRepositoryService.createDeploymentQuery().deploymentId("my-deployment-id").singleResult();
if (d != null) {
    eventRepositoryService.setDeploymentTenantId(d.getId(), "tenant-1");
}
Defensive patterns

Strategy: validation

Validate before calling

EventDeployment d = eventRepositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
if (d == null) throw new IllegalArgumentException("Unknown deployment: " + deploymentId);

Try / catch

try { eventRepositoryService.setDeploymentTenantId(id, tenant); } catch (FlowableObjectNotFoundException e) { log.warn("Deployment {} not found", id); }

Prevention

When it happens

Trigger: Calling the SetDeploymentTenantIdCmd command (or EventRepositoryService setDeploymentTenantId APIs) with a deploymentId that was never deployed, was already deleted, or belongs to a different event registry engine/database.

Common situations: Hardcoded or stale deployment ids after a redeployment (ids change per deployment), running against a wrong database schema, deleting deployments in one environment and reusing ids in another, or typo/whitespace in the id string.

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