2 Replies Latest reply on Dec 15, 2006 12:16 PM by jerzy stachera

    Saving TaksInstance, Task == NULL

    jerzy stachera Newbie

      I have a problem with saving task instance.

      First I create the process instance and then I save it.

      ProcessDefinition processDefinition = context.getGraphSession().findLatestProcessDefinition(pName);
      org.jbpm.graph.exe.ProcessInstance processInstance = new ProcessInstance(processDefinition);
      context.save(processInstance);


      In next step I retrieve the process instance and create the start task. It takes place in different method with new context.

      public static long createStartTaskInstance(int processInstanceId, JbpmDefSession session) throws Exception {
       JbpmContext context = session.getContext();
       try {
       ProcessInstance processInstance = context.getProcessInstance(processInstanceId);
       TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();
       context.save(taskInstance);
       return taskInstance.getId();
       }
       catch (Exception e) {
       log.error(e);
       }
       finally {
       context.close();
       }
       }
      


      After creating the start task instance I checked the JBPM_TASKINSTANCE table for this task. I found that the task data does not have a reference to task (task_ column is empty) as well as it has empty name_ column, the rest is ok. Because of that it is not possible to get the Task definition from the task instance:

      taskInstance.getTask()


      returns null.

      Where is the problem ?? Or maybe it can not be done in this way ??


        • 1. Re: Saving TaksInstance, Task == NULL
          jerzy stachera Newbie

          I forgot to attach procesddefinition.xml

          <?xml version="1.0" encoding="UTF-8"?>
          
          <process-definition
           xmlns="urn:jbpm.org:jpdl-3.1" name="SimpleSplitTest">
           <start-state name="start_state">
           <transition name="tr_start_left" to="task_left"></transition>
           <transition name="tr_start_right" to="task_right"></transition>
           </start-state>
           <task-node name="task_left">
           <transition name="tr_left_end" to="end_state"></transition>
           </task-node>
           <task-node name="task_right">
           <transition name="tr_right_end" to="end_state"></transition>
           </task-node>
           <end-state name="end_state"></end-state>
          </process-definition>


          • 2. Re: Saving TaksInstance, Task == NULL
            jerzy stachera Newbie

            Regarding my previous posts how it is possible that I have a taskinstance without reference to TASK DEFINITION. Is it some jBPM design gap or I am doing something wrong ??

            Any help to figure out this issue will be greatly appreciated :-)

            BR,
            Jurek