1 Reply Latest reply on Sep 24, 2009 7:01 PM by Christoph Wieser

    Losing variables of scope BUSINESS_PROCESS

    Christoph Wieser Newbie

      I am trying to implement the Google image labeler using Seam (2.2.0 GA/JBoss: 5.1.0 GA).



      • The entity gameSession (see below) holds the context for a game session.

      • The stateless component gameSessionBean (see below) manages the gameSession.

      • The workflow is defined as jbpm business process (see below).



      Unfortunately, I am losing the (game) business process variable while executing the business process.



      1. The process starts with the node start round and I can access #{gameSessionBean.startRound()} to start the round. Everyting seems to be alright according to the Eclipse debugger.

      2. The process forks to two players. Both need to pass their own task node ( label image), that can again access gameSessionBean without problems. Having labeled the image, the processing path joins again.

      3. However, in the transition end round after the jbpm join node, I cannot access gameSessionBean anymore. It is NULLed out. Why?



      I tried solutions that are proposed in the Web:


      * @BypassInterceptors for the entity
      * Using explicit @Out(scope = ScopeType.BUSINESS_PROCESS, required = false)
      



      What can I do to have a variable that is permanently scoped to the instance of a business process? Even the APPLICATION scope is not available during the execution of #{gameSessionBean.endRound()}. Is this a bug???


      This post may be related to:




      Code snippets:


      @Entity
      @Name("gameSession")
      @Scope(ScopeType.BUSINESS_PROCESS)
      public class GameSession implements Serializable {
              @GeneratedValue
              @Id
              private Integer id;
      [...]
      }
      



      @Name("gameSessionBean")
      @Scope(ScopeType.STATELESS)
      public class GameSessionBean implements Serializable {
      
              @In(create = true)
              @Out
              public GameSession gameSession;
      
              @CreateProcess(definition="")
              private String startBusinessProcess(String string) {
                    return "game"
              }
      
              @EndTask
              @StartTask
              public String startTask() {             
                      return "game";
              }
      }
      



      <?xml version="1.0" encoding="UTF-8"?>
      
      <process-definition name="gameImageLabeler">
              <start-state name="start">
                      <transition to="start round" name="start game"></transition>
              </start-state>
      
              <task-node name="[p1] label image">
                      <task name="labelImage" description="Player A">
                              <assignment actor-id="#{gameSessionBean.getPlayerId(0)}" />
                      </task>
                      <transition to="join1" name="[p1] wait for p2"></transition>
              </task-node>
      
              <task-node name="[p2] label image">
                      <task name="labelImage" description="Player B">
                              <assignment actor-id="#{gameSessionBean.getPlayerId(1)}" />
                      </task>
                      <transition to="join1" name="[p2] wait for p1"></transition>
              </task-node>
      
              <fork name="fork1">
                      <transition to="[p1] label image" name="[p1] label image"></transition>
                      <transition to="[p2] label image" name="[p2] label image">
                              <action></action>
                      </transition>
              </fork>
      
              <join name="join1">
                      <transition to="new or end" name="end round">
                              <action name="end round" expression="#{gameSessionBean.endRound()}"></action>
                      </transition>
              </join>
      
              <node name="start round">
                      <transition to="fork1" name="init round">
                              <action name="init round" expression="#{gameSessionBean.startRound()}"></action>
                      </transition>
              </node>
      
              <decision name="new or end"
                      expression="#{(gameSessionBean.hasNextRound()) ? 'to init round' : 'end game session'}">
                      <transition to="done" name="end game session"></transition>
                      <transition to="start round" name="to init round"></transition>
              </decision>
      
              <end-state name="done" />
      </process-definition>