1 Reply Latest reply on Dec 23, 2008 10:22 AM by Ronald van Kuijk

    Error in executing jbpm code

    Ajay Kamath Newbie

      i am runing below code code for Jbpm

      package com.sample.action;
      import java.util.ArrayList;
      import java.util.Collection;
      import java.util.Iterator;
      import java.util.List;

      import org.jbpm.graph.def.ProcessDefinition;
      import org.jbpm.graph.exe.ProcessInstance;
      import org.jbpm.graph.exe.Token;
      import org.jbpm.taskmgmt.def.Task;
      import org.jbpm.taskmgmt.exe.TaskInstance;

      public class TestWorkflow {

      public static void main(String args[])throws Exception {
      new TestWorkflow().execute();
      }

      public void execute() throws Exception {
      // Extract process from the processdefinition.xml file.
      ProcessDefinition processDefinition =ProcessDefinition.parseXmlResource("NewSample/processdefinition.xml");
      ProcessInstance instance =new ProcessInstance(processDefinition);


      displayStatus(instance);
      instance.signal();

      displayStatus(instance);
      executeTask(instance);


      displayStatus(instance);
      executeTask(instance);

      displayStatus(instance);


      }

      private void displayStatus(ProcessInstance instance) {


      String nodeName = instance.getRootToken().getNode().getName();
      System.out.println("task node executed: "+nodeName);

      }

      private void executeTask(ProcessInstance instance) {

      // Get the Task Instance List
      ArrayList taskList = new ArrayList(instance.getTaskMgmtInstance().getTaskInstances());
      System.out.println("length" +taskList.size());
      Iterator iter = taskList.iterator();

      while (iter.hasNext()) {

      TaskInstance taskInstance = (TaskInstance)iter.next();

      System.out.println("Found Task "+taskInstance.getName());
      System.out.println("Found Actor "+taskInstance.getActorId());

      taskInstance.end();
      System.out.println("Task completed");
      }

      }



      }
      i am getting the following error
      Exception in thread "main" java.lang.IllegalStateException: task instance '0' is already ended

      pls help...