{"record":{"id":"dac93d98319c2824","repo":"flowable/flowable-engine","slug":"no-process-instance-found-for-id-processinsta","errorCode":null,"errorMessage":"No process instance found for id = '${processInstanceId}'.","messagePattern":"No process instance found for id = '(.+?)'\\.","errorType":"validation","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/SetProcessDefinitionVersionCmd.java","lineNumber":84,"sourceCode":"        }\n        if (processDefinitionVersion == null) {\n            throw new FlowableIllegalArgumentException(\"The process definition version is mandatory, but 'null' has been provided.\");\n        }\n        if (processDefinitionVersion < 1) {\n            throw new FlowableIllegalArgumentException(\"The process definition version must be positive, but '\" + processDefinitionVersion + \"' has been provided.\");\n        }\n        this.processInstanceId = processInstanceId;\n        this.processDefinitionVersion = processDefinitionVersion;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        // check that the new process definition is just another version of the same\n        // process definition that the process instance is using\n        ExecutionEntityManager executionManager = CommandContextUtil.getExecutionEntityManager(commandContext);\n        ExecutionEntity processInstance = executionManager.findById(processInstanceId);\n        if (processInstance == null) {\n            throw new FlowableObjectNotFoundException(\"No process instance found for id = '\" + processInstanceId + \"'.\", ProcessInstance.class);\n        } else if (!processInstance.isProcessInstanceType()) {\n            throw new FlowableIllegalArgumentException(\"A process instance id is required, but the provided id \" + \"'\" + processInstanceId + \"' \" + \"points to a child execution of process instance \" + \"'\"\n                    + processInstance.getProcessInstanceId() + \"'. \" + \"Please invoke the \" + getClass().getSimpleName() + \" with a root execution id.\");\n        }\n\n        DeploymentManager deploymentCache = CommandContextUtil.getProcessEngineConfiguration(commandContext).getDeploymentManager();\n        ProcessDefinition currentProcessDefinition = deploymentCache.findDeployedProcessDefinitionById(processInstance.getProcessDefinitionId());\n\n        ProcessDefinition newProcessDefinition = deploymentCache\n                .findDeployedProcessDefinitionByKeyAndVersionAndTenantId(currentProcessDefinition.getKey(), processDefinitionVersion, currentProcessDefinition.getTenantId());\n\n        if (Flowable5Util.isFlowable5ProcessDefinition(currentProcessDefinition, commandContext) && !Flowable5Util\n            .isFlowable5ProcessDefinition(newProcessDefinition, commandContext)) {\n            throw new FlowableIllegalArgumentException(\"The current process definition (id = '\" + currentProcessDefinition.getId() + \"') is a v5 definition.\"\n                + \" However the new process definition (id = '\" + newProcessDefinition.getId() + \"') is not a v5 definition.\");\n        }\n\n        validateAndSwitchVersionOfExecution(commandContext, processInstance, newProcessDefinition);","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/SetProcessDefinitionVersionCmd.java#L66-L102","documentation":"execute() looks up the process instance by id via the ExecutionEntityManager. If no execution exists for the given id, it throws FlowableObjectNotFoundException typed to ProcessInstance, meaning the id does not reference any execution in the runtime database.","triggerScenarios":"Calling SetProcessDefinitionVersionCmd (or setProcessDefinitionVersion on the runtime service) with a processInstanceId that was deleted, already ended, never existed, or belongs to a different database/schema.","commonSituations":"Migrating instances after cleanup jobs removed completed instances; pointing at a historic instance (removed from ACT_RU_EXECUTION); typos in ids; wrong tenant/schema connection.","solutions":["Confirm the instance exists in ACT_RU_EXECUTION (runtime, not history) with the given id","Use the root process instance id from RuntimeService.createProcessInstanceQuery().processInstanceId(...) instead of a stored/copied value","Check the engine is connected to the correct database/schema where the instance lives"],"exampleFix":"// before\nmanagementService.executeCommand(new SetProcessDefinitionVersionCmd(\"123\", 3)); // id may not exist\n// after\nProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(\"123\").singleResult();\nif (pi != null) {\n    managementService.executeCommand(new SetProcessDefinitionVersionCmd(pi.getId(), 3));\n}","handlingStrategy":"try-catch","validationCode":"ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult();\nboolean exists = pi != null;","typeGuard":null,"tryCatchPattern":"try { cmd.execute(ctx); } catch (FlowableObjectNotFoundException e) { // fall back: check history\n    historyService.createHistoricProcessInstanceQuery().processInstanceId(id).singleResult(); }","preventionTips":["Query runtime service to confirm existence before migrating","Distinguish runtime vs historic instances","Ensure correct datasource/schema"],"tags":["process-instance","not-found","runtime"],"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"}