jBPM indeed has it's own hibernate session (there is an open jira for this), so the 'session closed' can come from there.
I do not fully understand what you mean by
but how to get there : I tried using JBpmContext,
How did you use the (Seam) JBpmContext? just like the normal JbpmContext?
My experience is that the integration needs some overhauling, and using a plain JbpmContext (the jBPM one, not the Seam one) works better. I've even developed an annotation that does the whole 'try/catch/finally' normally needed by jBPM and kind of 'injecting' the context into methods where needed to circumvent some jBPM/Seam problems
Some background about our new module:
We are including a new (road) traffic management task in our system. The idea is that we send a SMS message (already works) to a RoadInspector. He/she has a mobile phone and accept or refuse the message. When accepted the Process should start. The simplest way to implement this seemed the RestEasy interface. So the phone sends an userToken (we get the actor-id, by looking up the User in the DB) and taskId to a URL for every task and retrieves the next taskId as a reply. There are a number of steps defined and after the last task, the Traffic Isnpector is
freed-upfor a new Message.
The JBPMContext injection doesn't work directly in the REST-bean. There we get the message that it can only be used in a Transaction, so we moved the code to a EJB and that works (although we neede to add
to components.xml (simple bu very nasty hidden configuration setting I must say...)
Now the next step is to get the chain of request-replies working (nothing special, it's basically a simple reply-message). For the first step we need to get the taskId to the SMS-message. If we use the @CreateProcess annotation, the BPM context is not visible to us. So there is where the search begins.
- We need to start the process,
- We have to find the present-task for the selected Traffic Inspector.
I hoped to be able to use the jBPM-Seam annotations (I am a VERY lazy programmar) , and fill the taskId from the startTask through the requestparameter. But I am still fighting with the first step. How to get the taskId from the just started proces...
Did you also @StartTask something? Otherwise no taskid is associated with the conversation.
And maybe something like BusinessProcess.instance().... yields some results. Might be that you need to 'wrap' the method annotated with the @CreateProcess in another method and use it in this wrapper method. There might even be a business process id stored in the conversation, I do not remember that fully anymore.
I made some new test-routines to see what happens internally.
What strikes me is that the SLSB has full access to jBPM-context when called from the REST-service (with some help of
@TransactionAttribute(TransactionAttributeType.REQUIRED) on the method) , while I can't do the same on the REST-call.
At the moment I am accessing directly the jBPM-api and it's not so complex as expected, but I prefer doing it with annotations. I think the basics will be ready by tomorrow and I hope you can help me a bit to see if things can be optimized.
Basic things in the core jbpm 3 'api' is not that different from the wrapper Seam uses.
Sure, you may even send me a small project via mail at ronald @ mpbj (reverse) .org
You are welcome/Graag gedaan,
And regarding the access to the jBPM context or lack thereof in the REST service, do other injections work?
the first part works. I had some additional problems with Ajax, but that was solved when I use Async-calls with Observer.
One of the specific things of the REST-bean there is that is needs to have a Session-scope (otherwise the container calls remove on the used SFSB to early). The Session-Scope for REST prevents this and additionally it stays open until the session is no longer needed.
The first call is to acknowledge the received SMS. The phone calls the REST-service, which in turn calls the SFSB. I
injectthe jbpmContext, use the
normal jBPM API'sto create a new Process and return the taskId.to the REST-service which send that back as response to the phone.
The following calls are basically the same. I look up the task - handle all the functionality and end the task.
Nice combination of Seam and jBPM.
If done some workflow-stuff in the past, bit this save a lot of time !
P.S. The code needs some cleaning up, but I will definitely send it to the forum for some code walk-through..