AnsweredAssumed Answered

10 minute guide example, deployment fails

Question asked by rickhigh on Feb 1, 2011
Latest reply on Feb 2, 2011 by frederikheremans1
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?

Outcomes