2 Replies Latest reply on Nov 21, 2005 11:33 AM by pedro costa

    error in tasks-nodes

    pedro costa Apprentice

      this following code gives me an error leaving the task-node tn2. I don't understand what's wrong. I've checked and rechecked the code many times, and can't see what is the error.

      import org.jbpm.graph.def.ProcessDefinition;
      import org.jbpm.graph.exe.ProcessInstance;
      import org.jbpm.graph.exe.Token;
      import org.jbpm.taskmgmt.exe.TaskInstance;
      
      public class TaskAssignmentTest {
      
       public void testTaskAssignment() {
       ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
       "<process-definition name='the baby process'>" +
       " <start-state>" +
       " <transition name='to_tn1' to='tn1' />" +
       " </start-state>" +
      
       " <task-node name='tn1'>" +
       " <task name='t1'>" +
       " </task>" +
       " <transition name='to_state1' to='state1' />" +
       " </task-node>" +
      
       " <state name='state1'>" +
       " <transition name='to_tn2' to='tn2' />" +
       " </state>" +
      
       " <task-node name='tn2'>" +
       " <task name='t2'>" +
       " </task>" +
       " <transition name='to_tn3' to='tn3' />" +
       " </task-node>" +
      
       " <task-node name='tn3'>" +
       " <task name='t3'>" +
       " </task>" +
       " <transition name='to_end' to='end' />" +
       " </task-node>" +
      
       " <end-state name='end' />" +
       "</process-definition>"
       );
      
       System.out.println(processDefinition.toString());
      
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
       Token token = processInstance.getRootToken();
      
      
       token.signal();
      
       TaskInstance taskInstance = null;
      
       //TN1
       taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next();
       System.out.println("---> " + token.getNode().getName());
       taskInstance.end("to_state1");
       //taskInstance.end();
      
       //STATE1
       System.out.println(">>---> " + token.getNode().getName());
       token.signal();
      
       //TN2
       taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next();
       System.out.println("---> " + token.getNode().getName());
       taskInstance.end("to_tn3");
      
       //TN3
       taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next();
       System.out.println("---> " + token.getNode().getName());
      
       processInstance.end();
       }
       public static void main(String[] args){
       System.out.println("MAIN");
       TaskAssignmentTest tat = new TaskAssignmentTest();
       tat.testTaskAssignment();
       }
      }
      
      
      


      MAIN
      ProcessDefinition(the baby process)
      ---> tn1
      >>---> state1
      ---> tn2
      log4j:WARN No appenders could be found for logger (org.jbpm.jpdl.xml.JpdlXmlReader).
      log4j:WARN Please initialize the log4j system properly.
      java.lang.NullPointerException: task node does not have leaving transition 'to_tn3'
       at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:290)
       at com.sample.jbpm.taskmgmt.TaskAssignmentTest.testTaskAssignment(TaskAssignmentTest.java:68)
       at com.sample.jbpm.taskmgmt.TaskAssignmentTest.main(TaskAssignmentTest.java:79)
      Exception in thread "main"