11 Replies Latest reply on Oct 6, 2008 5:05 AM by Sascha Janz

    dynamically create tasks

    Sascha Janz Master

      i got the following code to generate dynamically tasks on a node.

       public Object execute(JbpmContext jbpmContext) throws Exception {
       // TODO Auto-generated method stub
       // TODO Auto-generated method stub
      
       Boolean b;
       try {
       b = Boolean.TRUE;
       ProcessInstance pi = jbpmContext
       .loadProcessInstance(processid);
       for (int i = 0; i < actors.size(); i++) {
       String actor = (String) actors.get(i);
       TaskInstance ti = pi.getTaskMgmtInstance()
       .createTaskInstance();
       ti.setActorId(actor);
       jbpmContext.save(ti);
       }
       jbpmContext.save(pi);
       } catch (Exception e) {
       // TODO: handle exception
       e.printStackTrace();
       b= Boolean.FALSE;
       }
       return b;
       }
      
      


      sometimes i got a nullpointer exception on

      TaskInstance ti = pi.getTaskMgmtInstance()

      the processid is set correct.

      any idea what might be wrong?