启动Activiti项目报错:org.activiti.engine.ActivitiObjectNotFoundException: no deployed process definition found with id '22501'
背景
- 启动activiti项目时,出现错误org.activiti.engine.ActivitiObjectNotFoundException: no deployed process definition found with id '22501'
原因
- 获取流程实例信息时,创建查询语句不正确
- 下面是出错的代码
//获取进程方法 RepositoryService repositoryService = processEngine.getRepositoryService(); RuntimeService runtimeService = processEngine.getRuntimeService1 //部署流程 DeploymentBuilder createDeployment = repositoryService.createDeployment(); DeploymentBuilder addClasspathResource = createDeployment.addClasspathResource("diagrams/Vacation.bpmn"); Deployment deploy = addClasspathResource.deploy(); //获取流程实例信息 DeploymentQuery createDeploymentQuery = repositoryService.createDeploymentQuery(); DeploymentQuery deploymentId = createDeploymentQuery.deploymentId(deploy.getId()); Deployment singleResult = deploymentId.singleResult(); //流程开始 Map<String, Object> vars = new HashMap<String, Object>(); vars.put("employeeName", "jingguoliang"); vars.put("numberOfDays", new Integer(4)); vars.put("VocationMotivation", "I will play with my friendgird"); ProcessInstance startProcessInstanceById = runtimeService.startProcessInstanceById(singleResult.getId(), vars);
- 下面是正确的代码
//获取进程方法 RepositoryService repositoryService = processEngine.getRepositoryService(); RuntimeService runtimeService = processEngine.getRuntimeService(); //定义流程 DeploymentBuilder createDeployment = repositoryService.createDeployment(); DeploymentBuilder addClasspathResource = createDeployment.addClasspathResource("diagrams/Vacation.bpmn"); Deployment deploy = addClasspathResource.deploy(); //获取流程实例信息 ProcessDefinitionQuery createProcessDefinitionQuery = repositoryService.createProcessDefinitionQuery(); ProcessDefinitionQuery deploymentId = createProcessDefinitionQuery.deploymentId(deploy.getId()); ProcessDefinition singleResult = deploymentId.singleResult(); //流程开始 Map<String, Object> vars = new HashMap<String, Object>(); vars.put("employeeName", "jingguoliang"); vars.put("numberOfDays", new Integer(4)); vars.put("VocationMotivation", "I will play with my friendgird"); ProcessInstance startProcessInstanceById = runtimeService.startProcessInstanceById(singleResult.getId(), vars);
- 修改即可