Rick

Rick
Rick

Tuesday, February 1, 2011

#activiti 10 minute guide example, deployment fails

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

I am getting the following error:

// Comment
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:


 

  
  
    
  
    
  
    
      Write monthly financial report for publication to shareholders.
    
    
      
        accountancy
      
    
  
    
  
      
  
    
      Verify monthly financial report composed by the accountancy department.
      This financial report is going to be sent to all the company shareholders.  
    
    
      
        management
      
    
  
    
  
      
  
      




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) {
  
  
  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? I will blog about the help I got and what worked.

1 comment:

Kafka and Cassandra support, training for AWS EC2 Cassandra 3.0 Training