javadeploymentactiviti

can not deploy process activiti


I am trying to implement the activiti example from activiti user guide, but my process wasn't deployed. There is no errors, no anything. My java code is :

public static void main(String[] args) {
   // TODO Auto-generated method stub
   ProcessEngine processEngine = null;
   ProcessEngineConfiguration processConfig= null;
   processConfig =  ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();

   processEngine = processConfig.buildProcessEngine();
   //Get Activiti services
   RepositoryService repositoryService = processEngine.getRepositoryService();
    RuntimeService runtimeService = processEngine.getRuntimeService();
    
    //Deploy the process definition
    repositoryService.createDeployment()
        .addClasspathResource("diagrams/FinancialReportProcess.bpmn20.xml")
        .deploy();
        System.out.println("Your process should be deployed...");
    
    //Start a process instance
    runtimeService.startProcessInstanceByKey("financialReport");
        System.out.println("Your process should be started...");

    
    // Get the first task
    TaskService taskService = processEngine.getTaskService();
    List<Task> tasks = taskService.createTaskQuery().taskCandidateGroup("accountancy").list();
    for (Task task : tasks) {
      System.out.println("Following task is available for accountancy group: " + task.getName());

      // claim it
      taskService.claim(task.getId(), "fozzie");
    }

    // Verify Fozzie can now retrieve the task
    tasks = taskService.createTaskQuery().taskAssignee("fozzie").list();
    for (Task task : tasks) {
      System.out.println("Task for fozzie: " + task.getName());

      // Complete the task
      taskService.complete(task.getId());
    }

    System.out.println("Number of tasks for fozzie: "
            + taskService.createTaskQuery().taskAssignee("fozzie").count());

    // Retrieve and claim the second task
    tasks = taskService.createTaskQuery().taskCandidateGroup("management").list();
    for (Task task : tasks) {
      System.out.println("Following task is available for management group: " + task.getName());
      taskService.claim(task.getId(), "kermit");
    }

    // Completing the second task ends the process
    for (Task task : tasks) {
      taskService.complete(task.getId());
    }
  }

and my FinancialReportProcess.bpmn20.xml code is:

 <?xml version="1.0" encoding="UTF-8"?>

 <definitions id="definitions"
  targetNamespace="http://activiti.org/bpmn20"
  xmlns:activiti="http://activiti.org/bpmn"
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL">

<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>

</definitions>

Solution

  • I think you should initialize your process engine like this,

    ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration() .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE) .setJdbcUrl("your jdbc url") .setJdbcUsername("username") .setJdbcPassword("password") .setAsyncExecutorEnabled(true) .setAsyncExecutorActivate(false) .buildProcessEngine();