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

    Injecting Business Process context scoped variables

    mgombocz

      Hi,

      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?

      Thx,
      Manuel

      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}" />
       </transition>
       </start-state>
      
       <task-node name="enter" end-tasks="true">
       <task name="enterDocumentation">
       <assignment actor-id="#{processInstance.contextInstance.variables['actorId']}"/>
       </task>
       <transition name="done" to="complete" />
       </task-node>
      
       <end-state name="complete"/>
      </process-definition>
      


      Methods "receive" and "assignToTimeSheet":
      @Stateless
      @Name("workEffortRecipient")
      public class WorkEffortRecipientBean implements WorkEffortRecipient,
       Serializable {
      
       // ... ...
      
       @In
       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) {
       // ... ...
       }
       }
      }
      
      [/url]

        • 1. Re: Injecting Business Process context scoped variables
          mgombocz

          What is also suprising is if I inject Seam component "processInstance" into "workEffortRecipient", this var is also null.

          Most probably this happens because jBPM writes its process instance variables into the database within a transaction of a separate hibernate session.

          But, shouldn't Seam hold outjected variables of scope=BUSINESS_PROCESS in its context (for later injections) for at least until jBPM has committed its transaction?

          If not, it would never be possible to define one or more actions in jPDL to be correctly be executed until the first wait-state occurred... And this would mean, that you can't use fine-grained Seam components in conjunction with jBPM workflows.

          Manuel

          • 2. Re: Injecting Business Process context scoped variables
            trouby

            Hey,

            Can anyone comment on this?

            (I'm having the same problems...)


            Thanks