{"record":{"id":"b8946c255b9ec566","repo":"flowable/flowable-engine","slug":"could-not-find-a-deployment-with-id-deploymenti-b8946c","errorCode":null,"errorMessage":"Could not find a deployment with id '${deploymentId}'.","messagePattern":"Could not find a deployment with id '(.+?)'\\.","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/persistence/deploy/EventDeploymentManager.java","lineNumber":227,"sourceCode":"            for (EventResourceEntity resource : resources) {\n                deployment.addResource(resource);\n            }\n\n            deployment.setNew(false);\n            deploy(deployment);\n            cachedChannelDefinition = channelDefinitionCache.get(channelDefinitionId);\n\n            if (cachedChannelDefinition == null) {\n                throw new FlowableException(\"deployment '\" + deploymentId + \"' didn't put channel definition '\" + channelDefinitionId + \"' in the cache\");\n            }\n        }\n        return cachedChannelDefinition;\n    }\n\n    public void removeDeployment(String deploymentId) {\n        EventDeploymentEntity deployment = deploymentEntityManager.findById(deploymentId);\n        if (deployment == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find a deployment with id '\" + deploymentId + \"'.\");\n        }\n\n        // Remove any event and channel definition from the cache\n        List<EventDefinition> eventDefinitions = new EventDefinitionQueryImpl().deploymentId(deploymentId).list();\n        List<ChannelDefinition> channelDefinitions = new ChannelDefinitionQueryImpl().deploymentId(deploymentId).list();\n\n        // Delete data\n        deploymentEntityManager.deleteDeployment(deploymentId);\n\n        FlowableEventDispatcher eventDispatcher = engineConfig.getEventDispatcher();\n\n        for (EventDefinition eventDefinition : eventDefinitions) {\n            eventDefinitionCache.remove(eventDefinition.getId());\n            if (eventDispatcher != null && eventDispatcher.isEnabled()) {\n                eventDispatcher.dispatchEvent(new FlowableEntityEventImpl(eventDefinition, FlowableEngineEventType.DEFINITION_UNDEPLOYED),\n                        EngineConfigurationConstants.KEY_EVENT_REGISTRY_CONFIG);\n            }\n        }","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/persistence/deploy/EventDeploymentManager.java#L209-L245","documentation":"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.","triggerScenarios":"Calling removeDeployment(deploymentId) with an id that was already deleted, never existed in this database, or belongs to another environment/tenant database.","commonSituations":"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.","solutions":["Check existence first with eventRepositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult() and skip if null.","Verify you are connected to the database/environment where the deployment was made.","Make deletion idempotent: wrap in an existence check or catch FlowableObjectNotFoundException.","If the deployment should exist, investigate cascade deletes or manual DB cleanup that removed it."],"exampleFix":"// before\neventRepositoryService.deleteDeployment(deploymentId); // throws if missing\n// after\nif (eventRepositoryService.createDeploymentQuery().deploymentId(deploymentId).count() > 0) {\n    eventRepositoryService.deleteDeployment(deploymentId);\n}","handlingStrategy":"validation","validationCode":"boolean exists = eventRepositoryService.createDeploymentQuery().deploymentId(deploymentId).count() > 0;\nif (!exists) return; // nothing to delete","typeGuard":null,"tryCatchPattern":"try {\n    eventRepositoryService.deleteDeployment(deploymentId);\n} catch (FlowableObjectNotFoundException e) {\n    // already gone; treat as success for idempotent cleanup\n}","preventionTips":["Make deployment deletion idempotent with an existence check.","Confirm the database/schema before running cleanup jobs.","Avoid reusing deployment ids across environments in scripts.","Guard against double execution of delete logic (retries, schedulers)."],"tags":["flowable","event-registry","delete","not-found"],"backgroundTag":"entity-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}