{"record":{"id":"0e0b1d59db17c9a7","repo":"flowable/flowable-engine","slug":"could-not-find-a-deployment-with-id","errorCode":null,"errorMessage":"Could not find a deployment with id ''.","messagePattern":"Could not find a deployment with id ''\\.","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-app-engine/src/main/java/org/flowable/app/engine/impl/deployer/AppDeploymentManager.java","lineNumber":130,"sourceCode":"            deployment.setNew(false);\n            deploy(deployment, null);\n            cachedAppDefinition = deployment.getAppDefinitionCacheEntry(appDefinitionId);\n\n            if (cachedAppDefinition == null) {\n                throw new FlowableException(\"deployment '\" + deploymentId + \"' didn't put app definition '\" + appDefinitionId + \"' in the cache\");\n            }\n        }\n        return cachedAppDefinition;\n    }\n    \n    public void removeDeployment(String deploymentId) {\n        removeDeployment(deploymentId, true);\n    }\n    \n    public void removeDeployment(String deploymentId, boolean cascade) {\n        AppDeploymentEntity deployment = deploymentEntityManager.findById(deploymentId);\n        if (deployment == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find a deployment with id '\" + deploymentId + \"'.\", AppDeploymentEntity.class);\n        }\n        \n        List<EngineDeployer> engineUnDeployers = new ArrayList<>(deployers);\n        engineUnDeployers.sort(Comparator.comparingInt(EngineDeployer::getUndeployOrder));\n\n        for (EngineDeployer deployer : engineUnDeployers) {\n            deployer.undeploy(deployment, cascade);\n        }\n\n        FlowableEventDispatcher eventDispatcher = appEngineConfiguration.getEventDispatcher();\n        for (AppDefinition appDefinition : new AppDefinitionQueryImpl().deploymentId(deploymentId).list()) {\n            appDefinitionCache.remove(appDefinition.getId());\n            if (eventDispatcher != null && eventDispatcher.isEnabled()) {\n                eventDispatcher.dispatchEvent(new FlowableEntityEventImpl(appDefinition, FlowableEngineEventType.DEFINITION_UNDEPLOYED),\n                        appEngineConfiguration.getEngineCfgKey());\n            }\n        }\n","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-app-engine/src/main/java/org/flowable/app/engine/impl/deployer/AppDeploymentManager.java#L112-L148","documentation":"FlowableObjectNotFoundException thrown by AppDeploymentManager.removeDeployment when no deployment with the given id exists in the app engine. The delete operation is refused because there is nothing to undeploy.","triggerScenarios":"Calling repositoryService.deleteDeployment(deploymentId) (with or without cascade) using an id that was already deleted, never existed, or belongs to a different engine's table prefix.","commonSituations":"Double-delete after an earlier cleanup script ran; deleting by a process/deployment id from flowable-engine instead of the app-engine deployment id; environment mismatch (dev id used against test DB); database recreated between steps.","solutions":["Check the id exists first via repositoryService.createDeploymentQuery().deploymentId(id).singleResult()","Ensure you use an app-engine deployment id (ACT_APP_DEPLOYMENT), not a process deployment id","Skip the delete if the deployment is already gone (idempotent handling)","Point the engine configuration at the database that actually holds the deployment"],"exampleFix":"// before\nrepoService.deleteDeployment(deploymentId);\n// after\nif (repoService.createDeploymentQuery().deploymentId(deploymentId).count() > 0) {\n    repoService.deleteDeployment(deploymentId);\n}","handlingStrategy":"validation","validationCode":"if (repoService.createDeploymentQuery().deploymentId(deploymentId).count() == 0) {\n    return; // already deleted or wrong id\n}\nrepoService.deleteDeployment(deploymentId);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Track deletion state to keep deletes idempotent","Confirm id source table (app engine, not process engine)","Catch FlowableObjectNotFoundException and treat as already-deleted"],"tags":["flowable","not-found","deployment","delete"],"backgroundTag":"record-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}