8 Replies Latest reply on Mar 12, 2011 1:29 PM by davidfdr.davidfdr.gmail.com

    Outjected ScopeType.BUSINESS_PROCESS JBPM variable scope: task or process?

    aconn7

      Are outjected BUSINESS_PROCESS variables scoped to the processInstance or taskInstance?  The processInstance would seem more natural, but in my experimentation, it seems to be taskInstance.


      I am attempting to outject a row id as documentId for reference throughout the life of my business process.  I am outjecting documentId upon @CreateProcess:


      @Name("rfcHome")
      public class RfcHome extends EntityHome<RfcBase> {
      
              @Out(scope = ScopeType.BUSINESS_PROCESS, required=false)        protected String documentId;    
      
              @Override @CreateProcess(definition="rfc")
              public String persist() {
                      String returnVal =  super.persist();
                      setDocumentId(getId().toString());
                      return returnVal;
              }
      
              public String getDocumentId() {
                      return documentId;
              }
      
              public void setDocumentId(String documentId) {
                      this.documentId = documentId;
              
      }
      



      This all seems to work fine and documentId is accessible when querying taskInstanceList for the first task in my jpdl :


              public List<TaskInstance> getDocumentTaskList(){
                      List<TaskInstance> filteredTaskInstanceList = new ArrayList<TaskInstance>();
                      for (TaskInstance task : taskInstanceList){
                              if (task.hasVariable("documentId")){
                                      Object object = task.getVariable("documentId");
                                      String documentId="";
                                      if (Long.class.isInstance(object)){
                                              documentId = ((Long)object).toString();
                                      } else {
                                              documentId = (String)object;
                                      }
                                      if (documentId.equalsIgnoreCase(rfcHome.getId().toString())){
                                              filteredTaskInstanceList.add(task);
                                      }
                              }
                              
                      }
                      return filteredTaskInstanceList;
              }
      



      This cool little filtering allows me to show the user their open tasks on a specific document.  Here is my jpdl:


      <process-definition  xmlns=""  name="rfc" >
              <start-state name="start">
                      <transition to="submit"/>
              </start-state>
       
              <task-node name="submit">
                      <description>
                              Submit for review
                      </description>
                      <task name="Complete new ECR">
                              <description>
                                      New RFC waiting for submit or cancel
                              </description>
                              <assignment actor-id="#{actor.id}"></assignment>                    
                      </task>
                      <transition name="submit" to="CCB Approve"/>
              </task-node>
      
              <task-node name="CCB Approve" create-tasks="false" >
                      <event type="node-enter">
                              <action expression="#{rfcJbpmAction.assignCcbApprovers}"   />
                      </event>
                      <description>Must be approved by each member of the CCB</description>               
                      <task name="ccbapproval" />
                      <transition to="end"></transition>
              </task-node>
              
              <end-state name='end' >
              </end-state>
      
      </process-definition>
      



      However ...

      After completing the submit task and transitioning to the CCB Approve task, documentId is no longer available.  Upon querying the jbpm_variableinstance table, I can see clearly that the TOKEN_, TOKENVARIABLEMAP_ and PROCESSINSTANCE_ column values are being NULL ed out.



      I am doing nothing particularly special or explicitly in my task completion component that would cause this:



      @Name("rfcJbpmTask")
      @AutoCreate
      public class RfcJbpmTask  {
              
              @In EntityManager entityManager;
              @In private RfcHome rfcHome;
              @In(required=false) private TaskInstance taskInstance;
              @In(required=false) private List<TaskInstance> taskInstanceList;
              @In(required=false) private ProcessInstance processInstance;
              
              public RfcJbpmTask() {}
                      
              
              @BeginTask @EndTask(transition="submit")
              public String submit(){
                      return "success";
              }
              
      }
      



      What is going on here? Shouldnt the variable be scoped to the processInstance ?  taskInstance scope seems to really limit the usefulness of being able to outject.


      As an alternative, I have resorted to explicitly creating variables in the jpdl itself.  This method has worked just fine:


              <start-state name="start">
                      <transition to="Status NEW Phase ECR">
                              <action name="Set DocumentId" expression="#{businessProcessContext.set(\'documentId\',rfcHome.id)}}"></action>
                      </transition>     
              </start-state>
      

        • 1. Re: Outjected ScopeType.BUSINESS_PROCESS JBPM variable scope: task or process?
          turpin_vincent

          Hi


          i've got the same problem, if someone can tell us where are outjected BUSINESSPROCESS variables...


          thanks in advance

          • 2. Re: Outjected ScopeType.BUSINESS_PROCESS JBPM variable scope: task or process?
            jetztmoginimmer

            I got a similar problem.

            • 3. Re: Outjected ScopeType.BUSINESS_PROCESS JBPM variable scope: task or process?
              jetztmoginimmer

              Got it! Inject your stuff manually, since @In is not evaluated:


              myEntity = (MyEntity) Component.getInstance("myEntity");
              

              • 4. Re: Outjected ScopeType.BUSINESS_PROCESS JBPM variable scope: task or process?
                armahdi

                i know its an OLLDDD post but if you guys here me: did you ever understood why is it not like that: WHY does the dvdstore example in the seam examples works perfectly fine...

                • 5. Re: Outjected ScopeType.BUSINESS_PROCESS JBPM variable scope: task or process?
                  armahdi

                  No thats not true yet !!!!


                  i just asked you on another thread the same thing ::: so i am posting here as well...


                  but here is the answer and i am going to post it on my thread and that thread as well..


                  You have no IDEA what kind of french is bursting out my mouth right now...



                  I had the same problem and those who are also having the same stupid problem.. the answer lies in the same dvd store example that comes in Seam:


                         
                  you have to add this... ofcourse for your own entity.. in dvd store example its the order...


                  <factory auto-create="true" name="order" scope="stateless"
                                  value="#{orderHome.instance}" />
                          <framework:entity-home auto-create="true"
                                  entity-class="com.jboss.dvd.seam.Order" name="orderHome" scope="conversation">
                                  <framework:id>#{orderId}</framework:id>
                          </framework:entity-home>




                  (If you are using entityHome objects for all your entities... you still need to use this but need to rename the orderHome to myorderhome or something else or it will complain with duplicates and


                  name=order



                  should be changed as well like


                  name="myorder"



                  cos that corresponds to the @factory(order) which will also complain for duplicates  and use that in your bean to @In Order myorder) and it will inject.

                  • 6. Re: Outjected ScopeType.BUSINESS_PROCESS JBPM variable scope: task or process?
                    aconn7

                    In the end, I was able to solve this problem in a totally different manner: OUTJECT SEAM!!!


                    I mean seriously.  I burned 2 plus years wrestling with this framework, trying to wrap my head around the nuanced concepts, configurations and complexities.  After digesting Dan Allen's Seam in Action, I finally felt I had some measure of mastery that would let me be productive.  Yet, I tempted fate and decided to add one last piece to the arsenal: JBPM integration.  It was thoroughly the most frustrating, agonizing experience to date.  And, I came to believe, Seam/JBPM is simply a clumsly, cobbled together half-baked integration.  Sure, you can mimick the demo stuff.  But try to do any meaningful workflow?  I only ever did get basic (and I do mean BASIC) workflow accomplished by by-passing all the inject/outjected SEAM stuff and just managing it myself underneath.


                    This whole experience pushed me over the edge and sent me looking for another framework, and I found it:  GWT, Guice, Spring, Hibernate.  Seriously: I was productive in the environment very quickly.  Why? Because it is SIMPLE and SIMPLE is always better.  Yes, JBoss/Seam sells you that this framework is simple. However, one reason it is not is that it is built on layers upon layers of an enormous software stack and you must have mastery over all of it, from bottom to top, to really leverage Seam in a way that is helpful.


                    To be fair, I jumped into the JBoss / Seam / Hibernate / Richfaces stack from ZERO knowledge of web development.  I had no one to hold my hand and recommend the path to enlightenment.  After some cursory research, I took it for granted that, being backed by Red Hat, JBOSS was the horse to ride.  While I can't argue it has it's place, it wasn't for me and I've not looked back.  I would compare Jboss / Seam stack vs GWT argument to the same EJB/J2EE vs. Spring.  Spring exploded in popularity because of how simple it was.  I have come to the belief that the existence of Seam was simply to justify and support J2EE/EJB in which Red Hat, via Jboss, is heavily invested.


                    Rant concluded,


                    Andy

                    • 7. Re: Outjected ScopeType.BUSINESS_PROCESS JBPM variable scope: task or process?
                      armahdi

                      LOL..



                      I should say you are pretty right I guess. I am trying my hands on Seam as well and I do have some exp in web application development, but either the Seam 2 has a buggy integration with jBPM or its just too bad.


                      Seam does have some power tough esp when you define components and you can get them in a certain scope. its pretty easy to code simple stuff though but in jBPM it just doesnt work that way,


                      Some how, may be I am doing something wrong, after each step the variables were becoming empty and secondly even if i re @Out them I need to make newly named variables the same names wont work some how. and the main pojo or entity around which the process actually revolves like  Order it just cannot be get cos of the Process varibale name was changed so now I ahve to make another EntityHome and new factory in the components.xml well i must be doing something wrong and I dotn get it as the dvdstore example works OK i replicated it but my own project doesnt work that way.


                      So yea it is kinda frustrating i guess.



                      Syed..

                      • 8. Re: Outjected ScopeType.BUSINESS_PROCESS JBPM variable scope: task or process?
                        davidfdr.davidfdr.gmail.com

                        I have the same problem.


                        I am allways outjecting the variable when the task is finished (@EndTask @End methods).



                        Well guys, to those who are disappointed with the jbpm seam support, look at the sources. I am implementing a lot of control lists objects just following the existent source codes.


                        Example: seam came with TaskIntanceListForType component but not the PooledTaskInstanceList. So, i have to code a PooledTaskInstanceListForType following the TaskInstanceListForType.


                        The only trouble that I am seeing on the jbpm integration is to use this with large amount of tasks and processes since my system has about 1000 users and 700 tasks creation / day. I will have to write from scratch all taskintancelists to work with paginated datascroller (not using memory pagination).


                        Sorry by the english.