Task Not Being Created?
jed204 Oct 12, 2006 6:18 PMI've been banging my head on this one and would like someone else (if they have some time) to take a look...
I've been using jBPM for general process and have just recently being trying to use some of the tasks. I've run into a problem and not sure why.
Basically, the problem I'm having is when I use a process definition from the database I can't get a task to be created. I can see the task node hit but no task is created. Using a process defintiion from a test case I can create a process and the task is created. Here are the two different methods of creating the same task:
/** Creates a test process using the coded definition */ public void startTestProcess() { logger.info("Starting Test Process via Coded Definition"); // Create a test process definition ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( "<process-definition name='the baby process'>" + " <start-state name='start'>" + " <transition name='baby cries' to='t'/>" + " </start-state>" + " <task-node name='t'>" + " <task name='change nappy'>" + " <assignment class='com.ider.Process.NappyAssignmentHandler'/>" + " </task>" + " <transition to='end'/>" + " </task-node>" + " <end-state name='end'/>" + "</process-definition>" ); // Create the process ProcessInstance processInstance = new ProcessInstance(processDefinition); // Signal the root token Token token = processInstance.getRootToken(); token.signal(); logger.info("Token Node: " + token.getNode()); } /** Creates a new process based on a process definition name */ public void startNewProcess(String processName) { JbpmContext jbpmContext = (JbpmConfigurationStatic.jbpmConfiguration).createJbpmContext(); try { logger.info("Starting Process via Definition [" + processName + "]"); // Load a process definition from the database ProcessDefinition myDef = jbpmContext.getGraphSession().findLatestProcessDefinition(processName); // Create the process ProcessInstance newProcess = new ProcessInstance(myDef); // Signal the root token Token token = newProcess.getRootToken(); token.signal(); logger.info("Token Node: " + token.getNode()); jbpmContext.save(newProcess); } finally { jbpmContext.close(); } }
One called right after another yields the following logs:
processAdmin.startTestProcess(); processAdmin.startNewProcess("Test");
Created via Coded Definition:
-----------------------------
18:03:37,875 INFO [UserAdminScreen] Starting Test Process via Coded Definition
18:03:37,875 DEBUG [GraphElement] event 'process-start' on 'ProcessDefinition(the baby process)' for 'Token(/)'
18:03:37,875 DEBUG [GraphElement] event 'before-signal' on 'StartState(start)' for 'Token(/)'
18:03:37,875 DEBUG [GraphElement] event 'node-leave' on 'StartState(start)' for 'Token(/)'
18:03:37,890 DEBUG [GraphElement] event 'transition' on 'Transition(baby cries)' for 'Token(/)'
18:03:37,890 DEBUG [GraphElement] event 'node-enter' on 'TaskNode(t)' for 'Token(/)'
18:03:37,890 DEBUG [GraphElement] event 'task-create' on 'Task(change nappy)' for 'Token(/)'
18:03:37,890 DEBUG [GraphElement] event 'task-assign' on 'Task(change nappy)' for 'Token(/)'
18:03:37,890 DEBUG [GraphElement] event 'after-signal' on 'StartState(start)' for 'Token(/)'
18:03:37,890 INFO [UserAdminScreen] Token Node: TaskNode(t)
Created via DB Definition:
--------------------------
18:03:41,015 INFO [UserAdminScreen] Starting Process via Definition [Test]
18:03:41,015 DEBUG [DbPersistenceServiceFactory] creating persistence service
18:03:41,015 DEBUG [DbPersistenceService] creating hibernate session
18:03:41,015 DEBUG [DbPersistenceService] beginning hibernate transaction
18:03:41,015 DEBUG [GraphElement] event 'process-start' on 'ProcessDefinition(Test)' for 'Token(/)'
18:03:41,015 DEBUG [GraphElement] event 'before-signal' on 'StartState(start)' for 'Token(/)'
18:03:41,015 DEBUG [GraphElement] event 'node-leave' on 'StartState(start)' for 'Token(/)'
18:03:41,031 DEBUG [GraphElement] event 'transition' on 'Transition(baby cries)' for 'Token(/)'
18:03:41,031 DEBUG [GraphElement] event 'node-enter' on 'TaskNode(t)' for 'Token(/)'
18:03:41,031 DEBUG [GraphElement] event 'node-leave' on 'TaskNode(t)' for 'Token(/)'
18:03:41,031 DEBUG [GraphElement] event 'transition' on 'Transition(248adb)' for 'Token(/)'
18:03:41,031 DEBUG [GraphElement] event 'node-enter' on 'EndState(end)' for 'Token(/)'
18:03:41,031 DEBUG [GraphElement] event 'process-end' on 'ProcessDefinition(Test)' for 'Token(/)'
18:03:41,031 DEBUG [GraphElement] event 'after-signal' on 'StartState(start)' for 'Token(/)'
18:03:41,031 INFO [UserAdminScreen] Token Node: EndState(end)
I see in the log where the coded definition creates the task but the definition from the db skips over. I just deployed the process to the database, it looks like the coded one:
<process-definition xmlns="" name="Test"> <start-state name="start"> <transition name="baby cries" to="t"/> </start-state> <task-node name="t"> <task name="change nappy"> <assignment class="com.ider.Process.NappyAssignmentHandler"/> </task> <transition to="end"/> </task-node> <end-state name="end"/> </process-definition>
btw, the NappyAssignmentHandler is straight from the examples.
Clearly, I've done something wrong...anyone care to take a guess?
Thanks in advance for any help!