0 Replies Latest reply on Jan 4, 2006 4:55 PM by Fred Muhlenberg

    task management - persistence Q (full code)

    Fred Muhlenberg Newbie

      Copying the task tutorial I can run it within jBoss. However, when
      I added some persistence (just like to comments say), it blows up.

      Would some please comment on why this code dies on line 114.

      jBPM v3.0.2

      Note: the xml is twikked for display

      71 System.out.println( "Creating task workflow..." );
      72 ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
      73 "< process-definition name='the baby process'>" +
      74 " < start-state>" +
      75 " < transition name='baby cries' to='waitfordad' />" +
      76 " < /start-state>" +
      77 " < task-node name='waitfordad'>" +
      78 " < task name='change nappy'>" +
      79 " < assignment class='workflow.task.NappyAssignmentHandler' />" +
      80 " < /task>" +
      81 " < transition to='end' />" +
      82 " < /task-node>" +
      83 " < end-state name='end' />" +
      84 "< /process-definition>"
      85 );
      86
      87 ProcessInstance processInstance =
      88 new ProcessInstance(processDefinition);
      89 Token token = processInstance.getRootToken();
      90
      91 token.signal();
      92 System.out.println( "We are at node: " + token.getNode().getName() );
      93
      94 long pid = processInstance.getId();
      95
      96 System.out.println( "Saving process instance... pid = " + pid);
      97 jbpmSession.beginTransaction();
      98 gs.saveProcessInstance( processInstance );
      99 jbpmSession.close();
      100
      101 System.out.println( "Cleared and done...");
      102 processInstance = null;
      102
      103 //------------------
      104
      105 jbpmSession = JbpmSessionFactory.getInstance().openJbpmSession();
      106 gs = jbpmSession.getGraphSession();
      107
      108 System.out.println( "Loading process instance from ID...");
      109 processInstance = gs.loadProcessInstance( pid );
      110
      111 TaskInstance taskInstance = (TaskInstance)
      112 processInstance
      113 .getTaskMgmtInstance()
      114 .getTaskInstances()
      115 .iterator().next();
      116
      117 System.out.println( "Task Instance assigned to " +
      118 taskInstance.getActorId() );
      119