2 Replies Latest reply on Dec 13, 2007 8:41 AM by asaf sh

    Injecting Business Process context scoped variables

    Manuel Gombocz Newbie


      I've defined a workflow that is started by a method called "receive(...)" (annotated with @CreateProcess). In this method I outject a variable named "workEffortId" into the Business Process context.

      My jPDL is rather short (start-node -> transition -> task-node -> transition -> end-node).

      In the 1st transition I have defined an action expression which calls a method called "assignToTimeSheet". In this method I inject variable "workEffortId" (Business Process context), but it is always null!

      If I call "assignToTimeSheet" in the 2nd transition, "workEffortId" gets the value that was outjected in "receive(...)".

      So, my assumption is that, because jBPM performs a transaction commit at the 1st wait-state (in this example at the task-node) and "assignToTimeSheet" is called before, Seam tries to read data that have not been committed yet, which results to a null value.

      Alternatively using an async node is not yet supported by Seam (see http://jira.jboss.com/jira/browse/JBSEAM-161).

      Does anybody has an idea how to solve this?


      PS. See my example code below (excerpts).

      Workflow "receiveWorkEffort"

      <?xml version="1.0"?>
      <process-definition name="receiveWorkEffort">
       <start-state name="start">
       <transition to="enter">
       <action expression="#{workEffortReception.assignToTimeSheet}" />
       <task-node name="enter" end-tasks="true">
       <task name="enterDocumentation">
       <assignment actor-id="#{processInstance.contextInstance.variables['actorId']}"/>
       <transition name="done" to="complete" />
       <end-state name="complete"/>

      Methods "receive" and "assignToTimeSheet":
      public class WorkEffortRecipientBean implements WorkEffortRecipient,
       Serializable {
       // ... ...
       private EntityManager entityManager;
       @In(scope = ScopeType.BUSINESS_PROCESS, required = false)
       @Out(scope = ScopeType.BUSINESS_PROCESS, required = false)
       private Long workEffortId;
       // ... ...
       @CreateProcess(definition = "receiveWorkEffort")
       public void receive(WorkEffortDTO effortDTO) {
       // ... ...
       workEffortId = workEffort.getId();
       // ... ...
       public void assignToTimeSheet() {
       // workEffortId is always null if called in the 1st transition
       if (workEffortId != null) {
       // ... ...