Process and task ids are only propagated inside the scope of a conversation. That's why @BeginTask begins a conversation and @EndTask ends one.
But note that neither @ResumeProcess nor @CreateProcess begin conversations. (By the way, @ResumeProcess will be massively improved, once I can get a feature request for "entity-driven processes" done in jBPM, so this is not yet perfect.)
So the answer is:
(1) make sure you have started a conversation
(2) make sure it is being propagated
Thank you very much for your response, Gavin!
I managed to get it working, but there's still a point I'm missing to get things clear. What I aimed at was a conversational stateful bean which controls the 'wizard'. So, I have a method which creates the process and a couple of methods which end the tasks according to the steps in the wizard. However, if annotate the methods with @EndTask, the stateful conversational bean gets destroyed. I assume that's because the end task ends the current conversation. Is there a way to avoid it?
One more question - is it possible, using the seam integration, to create a process and start a task at the same time, i.e. in the same method? In the method annotated with @CreateProcess I don't have the first taskId and the only way to do it seems to implement the org.jbpm.graph.def.ActionHandler.execute() method and get the taskId from th? ExecutionContext argument, but I'm not sure it's quite elegant way to do it. Is there something I'm missing or I'm just not grasping the idea properly?
The component named "businessProcess" gives you an API for controlling all these things independent of conversations. But you will have to use current CVS, since this API did not make it into 1.0.1.
Take care, I do not make any promises about the stability of CVS from day to day.
OK, I'll keep an eye on CVS changes.