-
1. Re: dynamically create tasks
salaboy21 Oct 3, 2008 9:44 AM (in response to ajanz)One of the first things that come into my mind is that you probably have an InvalidStateException because you are saving the task in a loop.
Check your StackTrace, and let us know if you find the problem. -
2. Re: dynamically create tasks
ajanz Oct 3, 2008 10:16 AM (in response to ajanz)no it was only called once.
but i must call it because i create n tasks.
or is there an other way to save it? -
3. Re: dynamically create tasks
kukeltje Oct 3, 2008 11:24 AM (in response to ajanz)like in another post... please make a unittest with embedded processdefinition that demonstrates (although it is not always here) the problem
-
4. Re: dynamically create tasks
ajanz Oct 3, 2008 12:25 PM (in response to ajanz)do i need to save the taskinstance seperate?
or would
jbpmContext.save(pi);
be enough? -
5. Re: dynamically create tasks
kukeltje Oct 3, 2008 12:44 PM (in response to ajanz)
or would
jbpmContext.save(pi);
be enough?
It should be -
6. Re: dynamically create tasks
ajanz Oct 4, 2008 4:42 PM (in response to ajanz)ok here is the test
public void testRuntimeTaskCreation() { ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( "<process-definition>" + "<start-state name='Start'>" + " <transition to='in Bearbeitung' name='beginnen'></transition>" + "</start-state> " + " <task-node name='in Bearbeitung' signal='never'> " + "<transition to='Ende' name='beenden' ></transition>" + "<transition to='in Bearbeitung' name='nicht zuständig, weitergeleitet'></transition>"+ "<transition to='in Bearbeitung' name='beantwortet'></transition> " + "<transition to='in Bearbeitung' name='nicht zuständig, zurück an Initiator'></transition>" + "</task-node>"+ "<end-state name='Ende'></end-state> </process-definition>"); ProcessInstance processInstance = new ProcessInstance(processDefinition); processInstance.signal("beginnen"); TaskMgmtInstance tmi = (TaskMgmtInstance) processInstance.getInstance(TaskMgmtInstance.class); TaskInstance ti = tmi.createTaskInstance(); if ( ti !=null) System.out.println("error creating task"); else System.out.println("Task created!"); }
-
7. Re: dynamically create tasks
kukeltje Oct 4, 2008 9:35 PM (in response to ajanz)You *DO* have to define a task in a task-node to create it runtime and have a create-tasks="false" attribute on the task-node.
Otherwise you have to runtime define the task to (can be done, but normally isn't)
In short: I'd suggest to use the testcases in the source of jBPM as a reference/examples. So much can be learned from them. -
8. Re: dynamically create tasks
kukeltje Oct 4, 2008 10:08 PM (in response to ajanz)Have you tried running this test at all? You should use the JbpmContext when creating processinstances... not like you do now... this gives error in my unittest (which uses asserts, not system.outs etc...)
-
9. Re: dynamically create tasks
kukeltje Oct 4, 2008 10:11 PM (in response to ajanz)ah... you do not use persistency at all here.... I did... next time post a full unittest not just one testmethod
-
10. Re: dynamically create tasks
kukeltje Oct 4, 2008 10:16 PM (in response to ajanz)oh... and I never get the nullpointer exception (ran the test 100 times).... not even when there is no task in the task-node. task Instance IS NOT NULL, so your system.out is WRONG.... please be more precise next time
-
11. Re: dynamically create tasks
ajanz Oct 6, 2008 5:05 AM (in response to ajanz)great!!! thank you. now it works
- i redefined the task node with createtask=false
- add also a task in the node
- coded the function exactly as in RuntimeTaskCreationTest