Activiti:没有使用密钥部署的进程

时间:2016-05-31 06:49:38

标签: java activiti

我在执行时遇到异常no processes deployed with key 'Process_MohitWorkflow'

ProcessInstance instance =
runtimeService.startProcessInstanceByKey(workflowName, businessKey, variables);

我的act_re_procdef表格中有一个关于此工作流程的条目

  

" Process_MohitWorkflow:1:14&#34 ;; 1;" http://www.activiti.org/processdef&#34 ;;"莫希特   信任&#34 ;;" Process_MohitWorkflow&#34 ;; 1;" 11&#34 ;;" MyBPMN.bpmn20.xml&#34 ;;" MyBPMN.Process_MohitWorkflow.png" ;"&#34 ;; FALSE; TRUE; 1;" 603"

<code>enter image description here</code>

我使用以下代码部署了MyBPMN.bpmn20.xml文件:

      public void deployProcessFile(String name, InputStream io, long tenantId) {
        RepositoryService repositoryService = processEngine.getRepositoryService();
        repositoryService.createDeployment()
                .addInputStream(name, io)
                .name(name.substring(0, name.indexOf(".")))
                .enableDuplicateFiltering()
                .tenantId(String.valueOf(tenantId))
                .deploy();
      }

堆栈跟踪:

Caused by: org.activiti.engine.ActivitiObjectNotFoundException: no processes deployed with key 'Process_MohitWorkflow'
    at org.activiti.engine.impl.persistence.deploy.DeploymentManager.findDeployedLatestProcessDefinitionByKey(DeploymentManager.java:125)
    at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:79)
    at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:37)
    at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
    at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
    at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
    at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
    at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
    at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceByKey(RuntimeServiceImpl.java:81)
    at com.vernuso.trust.server.service.ProcessService.startWorkFlowInstanceForEntity(ProcessService.java:265)
    at com.vernuso.trust.server.service.ProcessService.startOnboardingForOrganisation(ProcessService.java:221)
    at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:70)
    at com.vernuso.trust.server.governance.client.OnboardOrganisationActionHandler.executeTransaction(OnboardOrganisationActionHandler.java:44)
    at com.vernuso.trust.server.governance.client.OnboardOrganisationActionHandler.executeTransaction(OnboardOrganisationActionHandler.java:25)
    at com.vernuso.trust.server.SecuredActionHandler.execute(SecuredActionHandler.java:31)
    at com.gwtplatform.dispatch.rpc.server.AbstractDispatchImpl.doExecute(AbstractDispatchImpl.java:154)
    ... 48 more

对我可能缺少什么的想法?

问候。

3 个答案:

答案 0 :(得分:1)

我设法通过使用:

解决了这个问题
ProcessInstance instance = runtimeService.startProcessInstanceByKey(
  workflowName, businessKey, variables, tenantId);

而不是:

ProcessInstance instance = runtimeService.startProcessInstanceByKey(
  workflowName, businessKey, variables);

最初,我只依靠:

processEngine.getRepositoryService().createProcessDefinitionQuery() .processDefinitionTenantId(tenantId) .singleResult()

过滤掉基于tenantId的进程,但我认为这还不够。

不确定这是如何工作的(为什么我们必须提供额外的参数,即tenantId到startProcessInstance)或者在发布之前我应该​​做些什么才能看到这个。

答案 1 :(得分:0)

您可能无法使用RuntimeService::startProcessInstanceById()启动流程的另一个原因是,作为该方法的输入所需的id与xml文件中的id属性不同。 Activiti则将后者称为密钥。

RuntimeService::startProcessInstanceById()期望Activiti引擎在部署时生成的字符串ID。生成的ID的格式为key:version

答案 2 :(得分:-1)

尝试将子进程与原始进程一起部署:

 repositoryService.createDeployment()
                .addClasspathResource("diagrams/Process.bpmn")
                .deploy();

 repositoryService.createDeployment()
                .addClasspathResource("diagrams/Process_Subprocess.bpmn")
                .deploy();

我在junit中这样做,现在正在工作。