7 Replies Latest reply on Nov 16, 2007 4:50 AM by pmuir

    Problems understanding Seam's jBPM support

    mschmidke

      Hello all,

      I'm writing a Seam application which even uses jBPM for some simple business process.

      I have no problems using jBPM itself, but since I am using Seam, of course I want to use all benefits Seam gives to me, so I tried to understand chapters 7.3ff of Seam documentation, but there is still one big question:

      Which is the suggested way to work with jBPM objects in my own code? Mainly, how should I create the JbpmContext?

      Usually, I write:

      @In
      private org.hibernate.Session session;
      ...
      JbpmConfiguration config = JbpmConfiguration.getInstance();
      JbpmContext context = config.createJbpmContext();
      context.setSession(session);
      ProcessInstance pi = context.loadProcessInstanceForUpdate(72150L);
      ...
      context.close();
      


      This is the normal jBPM way. Is there also a seam improved way? For example, by injection?

      What about JbpmContext lifecycle? May I hold it in a SFSB Seam component field? (Can it be passivated?)

      In my SFSB, I use extended Hibernate Sessions as suggested by Seam:
      @Create
      @Begin(flushMode = FlushModeType.MANUAL)
      public void create() {
      }
      @End
      public String actionButton() {
       session.flush();
       return "startseite";
      }
      


      How can I combine this best with jBPM?

      Any suggestions?


      Marcus.


        • 1. Re: Problems understanding Seam's jBPM support
          arussel

           

          What about JbpmContext lifecycle? May I hold it in a SFSB Seam component field? (Can it be passivated?)

          Could you tell me if that worked ?
          For what I understand jbpm context delimit the transaction, and can use a transaction if one is active.
          So from creating jbpmcontext to closing it, it should stay on the same thread. I don't think this will happen if you keep it in a sfsb.
          alex

          • 2. Re: Problems understanding Seam's jBPM support
            mschmidke

            Indeed, keeping the context open for several transactions does not seem to work at all. It's a pity.

            But I continued my experiments and found that it seems not to be very bad to save a ProcessInstance to another JbpmContext than it was loaded from.

            So, for the moment, my workaround is to load ProcessInstances not forUpdate. In the action method which successfully ends the conversation, I open a new JbpmContext, save the ProcessInstance to that context and flush the hibernate session:

            @End
            public String actionButton() {
             JbpmContext ctx =
             JbpmConfiguration.getInstance().createJbpmContext();
             try {
             ctx.setSession(session);
             ctx.save(processInstance);
             } finally {
             ctx.close();
             }
             session.flush();
             return "startseite";
            }
            
            


            • 3. Re: Problems understanding Seam's jBPM support
              jcruise

              Just use injection to get the context:

              @In private JbpmContext jbpmContext;
              



              • 4. Re: Problems understanding Seam's jBPM support
                mschmidke

                 

                "jcruise" wrote:
                Just use injection to get the context:


                This was my hope ... but unfortunately it does not work:


                org.jboss.seam.RequiredException: In attribute requires non-null value: versionBearbeiten.jbpmContext


                Does jBPM in Seam need some kind of special configuration?

                I have in components.xml:

                <core:jbpm>
                 <core:process-definitions>
                 <value>Argos3Freigabeprozess/processdefinition.xml</value>
                 </core:process-definitions>
                </core:jbpm>
                


                , but I don't know if it's read because I found nothing about it in the logs.

                • 5. Re: Problems understanding Seam's jBPM support
                  mschmidke

                  Ok,

                  perhaps there is an error in chapter 7.4.1 of Seam documentation. I found out that the correct components.xml tag to install jBPM is bpm_jbpm, not core:jbpm.

                  This seems to bootstrap Seam's jBPM support.

                  For me, I'm facing other problems now, but I think it's worth opening a new thread.


                  Marcus.

                  • 6. Re: Problems understanding Seam's jBPM support
                    mschmidke

                    There was another typo ... bpm:jbpm, not bpm_jbpm.

                    For example:

                    <bpm:jbpm>
                     <bpm:process-definitions>
                     <value>Argos3Freigabeprozess/processdefinition.xml</value>
                     </bpm:process-definitions>
                    </bpm:jbpm>
                    


                    • 7. Re: Problems understanding Seam's jBPM support
                      pmuir

                      This is correct in the GA manual