7

I get an exception no processes deployed with key 'Process_MohitWorkflow' while executing:

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

I do have an entry in my act_re_procdef table for this workflow

"Process_MohitWorkflow:1:14";1;"http://www.activiti.org/processdef";"Mohit Trust";"Process_MohitWorkflow";1;"11";"MyBPMN.bpmn20.xml";"MyBPMN.Process_MohitWorkflow.png";"";FALSE;TRUE;1;"603"

<code>enter image description here</code>

I deployed my MyBPMN.bpmn20.xml file using the following code:

      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();
      }

StackTrace:

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

Any thoughts on what I might be missing?

Regards.

flavio.donze
  • 7,432
  • 9
  • 58
  • 91
EMM
  • 1,812
  • 8
  • 36
  • 58

3 Answers3

2

I managed to solve this issue by using:

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

Instead of:

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

Initially, I was relying only on:

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

to filter out the processes based on tenantId but I guess it was not sufficient.

Not sure how this works(why we must provide extra param i.e. tenantId to startProcessInstance) or what I should have done to see this before posting here.

EMM
  • 1,812
  • 8
  • 36
  • 58
0

Try to deploy subprocess along with original process:

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

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

I am doing this in junit and its working now.

pirho
  • 11,565
  • 12
  • 43
  • 70
0

Another reason you might not be able to start your process using RuntimeService::startProcessInstanceById() is that the id required as input to that method is not the same as the id attribute in your xml file. Activiti refers to the latter as the key instead.

RuntimeService::startProcessInstanceById() expects the String id that was generated at deploy time by the Activiti engine. The format of the generated id is key:version.