cancel
Showing results for 
Search instead for 
Did you mean: 

10 minute guide example, deployment fails

rickhigh
Champ in-the-making
Champ in-the-making
I am trying to get the 10 minute guide example to work in a standalone application.

I am getting the following error:


SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: no deployed process definition found with id 'financialReport'
   at org.activiti.engine.impl.db.DbRepositorySession.findDeployedProcessDefinitionById(DbRepositorySession.java:217)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:47)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:29)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:22)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:37)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceById(RuntimeServiceImpl.java:57)
   at com.demo.Demo.main(Demo.java:41)

I am running demo demo.start and the unit tests in the examples work.
I took the pom.xml from activiti-engine.examples and repurposed it for this example.


package com.demo;

import java.util.List;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.DeploymentQuery;
import org.activiti.engine.task.Task;

public class Demo {
   
   public static void main (String [] args) {
      ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
           .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
           .setJdbcUrl("jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000")
           .setDatabaseSchemaUpdate("create-drop")
           .setJobExecutorActivate(true)
           .buildProcessEngine();
      
      
      /* Deploy the xml file. */
      processEngine.getRepositoryService()
      .createDeployment().addClasspathResource("com/demo/demo-flow.bpmn20.xml").deploy();
      
      
      /* Start the process by id. */
      processEngine.getRuntimeService().startProcessInstanceById("financialReport");
            
      //fails with the above call with the above exception
   }


}


The above uses this demo-flow.bpmn20.xml:

<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
   xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
   xmlns:activiti="http://activiti.org/bpmn"
   targetNamespace="Examples">
   
<process id="financialReport" name="Monthly financial report reminder process">
 
  <startEvent id="theStart" />
   
  <sequenceFlow id='flow1' sourceRef='theStart' targetRef='writeReportTask' />
   
  <userTask id="writeReportTask" name="Write monthly financial report" >
    <documentation>
      Write monthly financial report for publication to shareholders.
    </documentation>
    <potentialOwner>
      <resourceAssignmentExpression>
        <formalExpression>accountancy</formalExpression>
      </resourceAssignmentExpression>
    </potentialOwner>
  </userTask>
   
  <sequenceFlow id='flow2' sourceRef='writeReportTask' targetRef='verifyReportTask' />
     
  <userTask id="verifyReportTask" name="Verify monthly financial report" >
    <documentation>
      Verify monthly financial report composed by the accountancy department.
      This financial report is going to be sent to all the company shareholders. 
    </documentation>
    <potentialOwner>
      <resourceAssignmentExpression>
        <formalExpression>management</formalExpression>
      </resourceAssignmentExpression>
    </potentialOwner>
  </userTask>
   
  <sequenceFlow id='flow3' sourceRef='verifyReportTask' targetRef='theEnd' />
     
  <endEvent id="theEnd" />
     
</process>
   <!–
   <process id="breakfast" name="Eat breakfast">

      <startEvent id="wakeUp" />

      <sequenceFlow id='wakeUpToEatBreakFastFlow' sourceRef='wakeUp'
         targetRef='eatBreakFast' />

      <userTask id="eatBreakFast" name="Eat a tasty breakfast">
         <documentation>
            Eat a tasty breakfast. Yum yum yum!!!
          </documentation>
         <potentialOwner>
            <resourceAssignmentExpression>
               <formalExpression>accountancy</formalExpression>
            </resourceAssignmentExpression>
         </potentialOwner>
      </userTask>

      <sequenceFlow id='eatBreakFastToVerifyKidsAte' sourceRef='eatBreakFast'
         targetRef='verifyKidsAte' />

      <userTask id="verifyKidsAte" name="Verify kids ate breakfast">
         <potentialOwner>
            <resourceAssignmentExpression>
               <formalExpression>management</formalExpression>
            </resourceAssignmentExpression>
         </potentialOwner>
      </userTask>

      <sequenceFlow id='verifyKidsAteToDone' sourceRef='verifyKidsAte'
         targetRef='done' />

      <endEvent id="done" />

   </process>
    –>

</definitions>


I have written some other code that works in the same project as follows:

package com.demo;

import org.activiti.engine.impl.pvm.ProcessDefinitionBuilder;
import org.activiti.engine.impl.pvm.PvmActivity;
import org.activiti.engine.impl.pvm.PvmExecution;
import org.activiti.engine.impl.pvm.PvmProcessDefinition;
import org.activiti.engine.impl.pvm.PvmProcessInstance;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.activiti.engine.impl.pvm.delegate.SignallableActivityBehavior;


public class DemoUsingFluentAPI {
   
   static PvmProcessDefinition processDefinition = new ProcessDefinitionBuilder()
     .createActivity("find bacon")
       .initial()
       .behavior(new MyActivityBehavior())
       .transition("find eggs")
     .endActivity()
     .createActivity("find eggs")
       .behavior(new MyActivityBehavior2())
       .transition("find orange juice")
     .endActivity()
     .createActivity("find orange juice")
       .behavior(new MyActivityBehavior3())
     .endActivity()
     .buildProcessDefinition();

   
   public static class MyActivityBehavior implements SignallableActivityBehavior {

      public void execute(ActivityExecution execution) throws Exception {
         System.out.println("Here ");
         execution.take(execution.getActivity().getOutgoingTransitions().get(0));
      }

      public void signal(ActivityExecution arg0, String arg1, Object arg2)
            throws Exception {
         System.out.println("Here signal");         
      }
      
   }
   
   public static class MyActivityBehavior2 implements SignallableActivityBehavior {

      public void execute(ActivityExecution execution) throws Exception {
         System.out.println("Here 2");
         execution.take(execution.getActivity().getOutgoingTransitions().get(0));
      }

      public void signal(ActivityExecution arg0, String arg1, Object arg2)
            throws Exception {
         System.out.println("Here signal 2");
         
      }
      
   }
   
   public static class MyActivityBehavior3 implements SignallableActivityBehavior {

      public void execute(ActivityExecution execution) throws Exception {
         System.out.println("Here 3");
         execution.end();
      }

      public void signal(ActivityExecution arg0, String arg1, Object arg2)
            throws Exception {
         System.out.println("Here signal 3");
      }
      
   }


   public static void main (String [] args) {
//      ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
//           .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
//           .setJdbcUrl("jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000")
//           .setDatabaseSchemaUpdate("create-drop")
//           .setJobExecutorActivate(true)
//           .buildProcessEngine();
//      
//      RuntimeService runtimeService = processEngine.getRuntimeService();
      
      
      
      PvmProcessInstance processInstance = processDefinition.createProcessInstance();
      processInstance.start();
      
      PvmActivity activity = processDefinition.findActivity("find bacon");
      activity.findOutgoingTransition("find eggs");
      
      PvmExecution activityInstance = processInstance.findExecution("find bacon");
      assert activityInstance!=null : "Not Null";
            
      
      
   }

}


Can I get some ideas on how to debug this?
5 REPLIES 5

rickhigh
Champ in-the-making
Champ in-the-making
I went through the tutorial for the eclipse plugin and it worked.
Well, the unit test worked in the unit test only.


package org.activiti.designer.test;



import java.util.HashMap;
import java.util.Map;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.test.Deployment;
import org.activiti.engine.test.ActivitiRule;
import org.junit.Rule;
import org.junit.Test;

public class ProcessTestHelloworld {

@Rule
public ActivitiRule activitiRule = new ActivitiRule();

@Test
@Deployment(resources="diagrams/my_bpmn2_diagram.activiti.bpmn20.xml")
public void startProcess() {
  RuntimeService runtimeService = activitiRule.getRuntimeService();
  Map<String, Object> variableMap = new HashMap<String, Object>();
  variableMap.put("name", "Activiti");
  variableMap.put("color", "BLUE");
  runtimeService.startProcessInstanceByKey("helloworld", variableMap);
}
}


However, I don't know how to run it standalone.

I tried writing a main method that loads the same process.


package com.demo;

import java.util.List;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.task.Task;

public class Demo {

public static void main (String [] args) {
  ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
     .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
     .setJdbcUrl("jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000")
     .setDatabaseSchemaUpdate("create-drop")
     .setJobExecutorActivate(true)
     .buildProcessEngine();
 
 
  /* Deploy the xml file. */
  processEngine.getRepositoryService()
  .createDeployment().addClasspathResource("diagrams/my_bpmn2_diagram.activiti.bpmn20.xml").deploy();
 
  /* Start the process by id. */
  processEngine.getRuntimeService().startProcessInstanceById("helloworld");
   
  List<Task> tasks = processEngine.getTaskService()
    .createTaskQuery().taskCandidateUser("fozzie").list();
 
  System.out.println("Got some tasks " + tasks);
  for (Task task : tasks) {
   System.out.println(task.getId());
  }
}


}


I get the same exception I was getting before (well similar).

Feb 1, 2011 5:08:47 PM org.activiti.engine.impl.ProcessEngineImpl <init>
INFO: ProcessEngine default created
Feb 1, 2011 5:08:47 PM org.activiti.engine.impl.jobexecutor.JobAcquisitionThread run
INFO: JobAcquisitionThread starting to acquire jobs
Feb 1, 2011 5:08:47 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
INFO: Processing resource diagrams/my_bpmn2_diagram.activiti.bpmn20.xml
Feb 1, 2011 5:08:47 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XMLSchema currently not supported as typeLanguage
Feb 1, 2011 5:08:47 PM org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XPath currently not supported as expressionLanguage
Feb 1, 2011 5:08:49 PM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: no deployed process definition found with id 'helloworld'
at org.activiti.engine.impl.db.DbRepositorySession.findDeployedProcessDefinitionById(DbRepositorySession.java:217)
at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:47)
at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:29)
at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:22)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:37)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceById(RuntimeServiceImpl.java:57)
at com.demo.Demo.main(Demo.java:25)
Exception in thread "main" org.activiti.engine.ActivitiException: no deployed process definition found with id 'helloworld'
at org.activiti.engine.impl.db.DbRepositorySession.findDeployedProcessDefinitionById(DbRepositorySession.java:217)
at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:47)
at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:29)
at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:22)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:37)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceById(RuntimeServiceImpl.java:57)
at com.demo.Demo.main(Demo.java:25)


I want just a simple standalone example (that is not a unit test) that works.

BTW I did explore and try a few things with the unit test so I am not completely stuck.
Also the screenshots and generated code for the tutorial do not match the current plugin.

10 minute guide missing pieces.
Working tutorial with old screenshots.

frederikherema1
Star Contributor
Star Contributor
Hi,

You should use the startProcessInstanceByKey('financialProcess') instead of startProcessInstanceById(''), this will fix your problem.

Activiti is an open-source project and has a large community of contributors. The Designer is completely contributed by a team in Holland, which do this after (!) their normal day-job, so they may have missed the userguide-update this time (we do monthly release, and designer functionality has grown a lot this month).

I'm not sure the best way to get help from us/our community is to tweet how #activiti #fails though…

jbarrez
Star Contributor
Star Contributor
I understand your criticism, the userguide must reflect the current state of things.

I've created following JIRA issues and planned them on release 5.3: http://jira.codehaus.org/browse/ACT-601 and http://jira.codehaus.org/browse/ACT-600

rickhigh
Champ in-the-making
Champ in-the-making
frederikheremans Thanks for your help that works well.

In the XML file, the attribute is called "id", and you have two methods with nearly identical names.

It is a bit confusing and code completion filled in the blanks. I did not even notice that they were different.

I thought I was cutting/pasting them out of the docs.

In any regard, it works now… thanks.

Regarding #fail, I was referring to my effort to get the 10 minute example to work. I will continue to tweet unabated.

It is clear to me that the failure was on my part for calling the wrong method.

Thanks again for your help.

frederikherema1
Star Contributor
Star Contributor
Rick,

It's indeed a bit confusing that the process-definition "id" in the xml (bpmn 2.0 style), is actually the process key in activiti-terms.
You can tweet unbated, be my guest Smiley Wink Keep on spreading the #activiti word!