2 Replies Latest reply on Aug 29, 2006 7:10 PM by kukeltje

    Problem creating Process Instance and Tasks

    jmjava

      I am trying to creat a simple web application that demonstrates moving a token through a process and assigning users to tasks during the process.

      I am using the Spring Modules package to configure my JBPM engine. When i try to create a processInstance and signal the token it appears that my Taskinstance is not getting creating for my first task.

      Here is my simple process Definition:

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

      <process-definition name="3step">

      <!-- START-STATE -->
      <start-state name="start">

      </start-state>

      <!-- NODES -->
      <end-state name="end"/>
      <task-node name="task1">

      </task-node>
      <task-node name="task2">

      </task-node>
      <task-node name="task3">

      </task-node>

      </process-definition>


      Here is the code in my servlet:

      webContext = WebApplicationContextUtils
      .getRequiredWebApplicationContext(getServletContext());

      jbpmConfiguration = (JbpmConfiguration) webContext
      .getBean("jbpmConfiguration");

      JbpmTemplate jbpmTemplate = (JbpmTemplate) webContext
      .getBean("jbpmTemplate");



      ProcessDefinition pd = jbpmTemplate.getProcessDefinition();


      ProcessInstance processInstance = new ProcessInstance(pd);

      Token token = processInstance.getRootToken();

      token.signal();

      TaskInstance task1 = getTaskInstanceByTaskName(processInstance, "task1");
      task1.setActorId("me");

      .........


      private TaskInstance getTaskInstanceByTaskName(ProcessInstance processInstance, String taskName){

      Collection taskInstances = processInstance
      .getTaskMgmtInstance()
      .getTaskInstances();
      // this collection is always null????

      Iterator i = taskInstances.iterator();

      TaskInstance currentTask = null;

      while (i.hasNext()){
      TaskInstance task = (TaskInstance)i.next();

      if (task.getName().equals(taskName)){
      currentTask = task;
      break;
      }
      }

      return currentTask;


      }

      Can anyone shed some light on why there is no task instance for this processInstance after the token.signal() is processed?

        • 1. Re: Problem creating Process Instance and Tasks
          jbpmndc

          Have you tried it in standalone mode, like the 'purchasing' example?

          If it works there, than it's an app server configuration problem.

          • 2. Re: Problem creating Process Instance and Tasks
            kukeltje

            look at the examples/testcases. There are lots of errors and wrong assumptions in your code/process. (use the code tags btw for good formatting).

            There are NO tasks in your process definition, so NO taskinstances if you start the process.

            And as jbpmndc states, try it standalone in a unit test first (See Test Driven Development in the docs and sourcecode of jBPM)