{"record":{"id":"c1cfaeeb72e1a6f6","repo":"flowable/flowable-engine","slug":"cannot-find-process-definition-for-id-processde-c1cfae","errorCode":null,"errorMessage":"Cannot find process definition for id '${processDefinitionId}'","messagePattern":"Cannot find process definition for id '(.+?)'","errorType":"exception","errorClass":"ActivitiObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/AbstractSetProcessDefinitionStateCmd.java","lineNumber":103,"sourceCode":"        // If process definition is already provided (eg. when command is called through the DeployCmd)\r\n        // we don't need to do an extra database fetch and we can simply return it, wrapped in a list\r\n        if (processDefinitionEntity != null) {\r\n            return Collections.singletonList(processDefinitionEntity);\r\n        }\r\n\r\n        // Validation of input parameters\r\n        if (processDefinitionId == null && processDefinitionKey == null) {\r\n            throw new ActivitiIllegalArgumentException(\"Process definition id or key cannot be null\");\r\n        }\r\n\r\n        List<ProcessDefinitionEntity> processDefinitionEntities = new ArrayList<>();\r\n        ProcessDefinitionEntityManager processDefinitionManager = commandContext.getProcessDefinitionEntityManager();\r\n\r\n        if (processDefinitionId != null) {\r\n\r\n            ProcessDefinitionEntity processDefinitionEntity = processDefinitionManager.findProcessDefinitionById(processDefinitionId);\r\n            if (processDefinitionEntity == null) {\r\n                throw new ActivitiObjectNotFoundException(\"Cannot find process definition for id '\" + processDefinitionId + \"'\", ProcessDefinition.class);\r\n            }\r\n            processDefinitionEntities.add(processDefinitionEntity);\r\n\r\n        } else {\r\n\r\n            ProcessDefinitionQueryImpl query = new ProcessDefinitionQueryImpl(commandContext).processDefinitionKey(processDefinitionKey);\r\n\r\n            if (tenantId == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(tenantId)) {\r\n                query.processDefinitionWithoutTenantId();\r\n            } else {\r\n                query.processDefinitionTenantId(tenantId);\r\n            }\r\n\r\n            List<ProcessDefinition> processDefinitions = query.list();\r\n            if (processDefinitions.isEmpty()) {\r\n                throw new ActivitiException(\"Cannot find process definition for key '\" + processDefinitionKey + \"'\");\r\n            }\r\n\r","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/AbstractSetProcessDefinitionStateCmd.java#L85-L121","documentation":"findProcessDefinition() looks up the definition by id via ProcessDefinitionEntityManager.findProcessDefinitionById(). If no definition exists for the supplied id, it throws ActivitiObjectNotFoundException with ProcessDefinition.class as the missing object type. The id is well-formed but does not correspond to any deployed process definition.","triggerScenarios":"Calling suspend/activate by id (SetProcessDefinitionStateCmd with processDefinitionId set) where the id is stale, misspelled, from a different database/tenant, or the deployment was deleted.","commonSituations":"Hardcoded definition ids copied between environments (test id used in prod); definition redeployed producing a new id; cascade suspension by key attempted with an old id; multi-database setups referencing the wrong schema.","solutions":["Verify the id exists: repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult() before suspending/activating.","Prefer suspend/activate by key (latest version) instead of a pinned id, so redeployments don't invalidate it.","List available definitions (createProcessDefinitionQuery().list()) and use the correct id for the target environment.","Check tenant/database configuration if the definition was deployed elsewhere."],"exampleFix":"// before\nrepositoryService.suspendProcessDefinitionById(\"orderProcess:1:999\"); // stale id\n// after\nProcessDefinition pd = repositoryService.createProcessDefinitionQuery()\n    .processDefinitionKey(\"orderProcess\").latestVersion().singleResult();\nrepositoryService.suspendProcessDefinitionById(pd.getId());","handlingStrategy":"validation","validationCode":"ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();\nif (pd == null) throw new IllegalArgumentException(\"Unknown process definition id: \" + id);","typeGuard":null,"tryCatchPattern":"try { repositoryService.suspendProcessDefinitionById(id); } catch (ActivitiObjectNotFoundException e) { if (e.getObjectClass() == ProcessDefinition.class) { log.error(\"No definition for id {} — check environment/deployment\", id); } throw e; }","preventionTips":["Resolve the id via ProcessDefinitionQuery before by-id operations.","Prefer by-key operations to survive redeployments.","Never hardcode definition ids across environments.","Check tenant/database targeting when ids appear missing."],"tags":["not-found","process-definition","object-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"}