2 Replies Latest reply on May 1, 2006 2:26 PM by Torsten Hartwig

    task is not blocking after save of process-instance

    Torsten Hartwig Newbie

      Hi all,

      i wrote a little test which refers to the following process-definition:

      <process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="standardprocess">
       <start-state name="start">
       <transition name="start" to="task"></transition>
       </start-state>
       <end-state name="end"></end-state>
       <task-node name="task" create-tasks="true">
       <task name="dummytask" blocking="true"></task>
       <transition name="stop" to="end"></transition>
       </task-node>
      </process-definition>


      In my test-class i create a new process-instance, call a signal on the root-token and save the process-instance. So the root-token of the persistent process-instance remains in the task-node and a blocking task-instance has been created automatically. After reloading the process-instance and calling a signal again, the root-token leaves the task-node, although the blocking task-instance has not been ended. In my opinion the root-token is not allowed to leave the task node. So i started the debugger and stepped into the leave()-method of TaskNode and find out that the check tmi.hasBlockingTaskInstances(executionContext.getToken()) fails, because the token-instance in execution-context an the token-instance in the (persistent) task-instance differ. What i mean is taskInstance.getToken()!=executionContext.getToken(), because the token in the task-instance is a hibernate proxy and the token in the execution-context is a "real" token). My test-class is as follows:

      import junit.framework.TestCase;
      import org.jbpm.JbpmConfiguration;
      import org.jbpm.JbpmContext;
      import org.jbpm.graph.def.ProcessDefinition;
      import org.jbpm.graph.exe.ProcessInstance;
      
      public class StandardprocessTest extends TestCase {
      
       JbpmConfiguration jbpmConfiguration = null;
      
       ProcessDefinition processDefinition = null;
      
       ProcessInstance processInstance = null;
      
       protected void setUp() throws Exception {
       jbpmConfiguration = JbpmConfiguration.getInstance();
      
       jbpmConfiguration.createSchema();
      
       processDefinition = ProcessDefinition
       .parseXmlResource("standardprocess.par/processdefinition.xml");
       }
      
       protected void tearDown() throws Exception {
       }
      
       public void testStandardprocess() {
      
       long processInstanceId;
      
       JbpmContext jbpmContext1 = jbpmConfiguration.createJbpmContext();
      
       try {
      
       jbpmContext1.deployProcessDefinition(processDefinition);
      
       processInstance = jbpmContext1
       .newProcessInstanceForUpdate("standardprocess");
       assertNotNull(processInstance);
       processInstanceId = processInstance.getId();
      
       processInstance.signal();
      
       } finally {
       // Implicit save
       jbpmContext1.close();
       }
      
       JbpmContext jbpmContext2 = jbpmConfiguration.createJbpmContext();
      
       try {
      
       jbpmContext2.deployProcessDefinition(processDefinition);
      
       processInstance = jbpmContext2
       .loadProcessInstanceForUpdate(processInstanceId);
       assertNotNull(processInstance);
      
       assertEquals("task", processInstance.getRootToken().getNode()
       .getName());
      
       // Should not be allowed
       processInstance.signal();
      
       } finally {
       // Implicit save
       jbpmContext2.close();
       }
       }
      }


      Any suggestions?

      Thanks,
      Torsten