6 Replies Latest reply on Aug 31, 2010 2:44 PM by lvdberg

    jBPM process does not start?

    sirlantis

      Hi everybody,


      I stumbled over jBPM a few days ago and now I am trying to integrate it into my project. But since I'd like to play around with it a little bit I created a dummy-view with a button to create a process (called order). It's bound to the createProcess() method.


           public void createProcess()
           {
                createJbpmProcess();
           }
           
           @CreateProcess(definition="order")
           private String createJbpmProcess()
           {
                log.info(TestHelper.class.getCanonicalName(), "started jBPM process");
                return "success";
           }
      



      Logger prints the given line but



      • No ProcessInstance is persisted into the database

      • server.log doesn't state anything about a process being created

      • The action expression (in my start-node) isn't evaluated (System.out.println(hi)).



      I'd expect at least one of those to happen.
      How can I find out if my Process is created correctly?
      Or did I do something wrong?


      Thanks for your help!

        • 1. Re: jBPM process does not start?
          wrzep

          Marcel,


          A call to createJbpmProcess() isn't a call to a Seam proxy. It's just normal java call. That is why the @CreateProcess annotation has no effect.


          Cheers,
          -Pawel

          • 2. Re: jBPM process does not start?
            sirlantis

            Thanks for the fast reply, Pawel.


            Works just fine now - Another thing learned about Seam.

            • 3. Re: jBPM process does not start?
              uesker

              Hi!
              How can I use that approach and still call a seam proxy.


              Examplaxe



              public void begin() {
                  if there is an already process deploy {
                    do something;
                    return "/page.xhtml";
                  } else {
                      createJbpmProcess();
                  }
               }
              
               @CreateProcess(definition="order")
               private String createJbpmProcess()
               {
                   log.info(TestHelper.class.getCanonicalName(), "started jBPM process");
                   return "/page.xhtml";
               }   
              



              • 4. Re: jBPM process does not start?
                lvdberg

                Hi,


                You have to look up the processinstance with the help of jbpmContext. The method which you call must be transactional and (because you want it to be conditional) should start up the procees itself - without the annotation,


                The next does more or less what you want to do:



                @In(required = false) JbpmContext jbpmContext;
                
                @Transactional
                public void startSomething(){
                  // find the instance using the processdefinition 
                GraphSession gs = jbpmContext.getGraphSession();
                ProcessDefinition def = gs.findLatestProcessDefinition("order");
                  // The next will return null if there is no such instance present
                  // Be aware that this is a sort of Singleton process, so you just can have on
                  // ProcessInstance with this approach...
                  ProcessInstance pi = jbpmContext.getProcessInstance(def, null);
                  if (pi == null) {
                   ProcessInstance pi = new ProcessInstance(def);
                   Token tkn = pi.getRootToken();
                   tkn.signal();
                  etc, etc.
                
                ....
                }





                • 5. Re: jBPM process does not start?
                  uesker

                  Leo van den Berg wrote on Aug 30, 2010 14:38:


                  Hi,

                  You have to look up the processinstance with the help of jbpmContext. The method which you call must be transactional and (because you want it to be conditional) should start up the procees itself - without the annotation,

                  The next does more or less what you want to do:


                  @In(required = false) JbpmContext jbpmContext;
                  
                  @Transactional
                  public void startSomething(){
                    // find the instance using the processdefinition 
                  GraphSession gs = jbpmContext.getGraphSession();
                  ProcessDefinition def = gs.findLatestProcessDefinition("order");
                    // The next will return null if there is no such instance present
                    // Be aware that this is a sort of Singleton process, so you just can have on
                    // ProcessInstance with this approach...
                    ProcessInstance pi = jbpmContext.getProcessInstance(def, null);
                    if (pi == null) {
                     ProcessInstance pi = new ProcessInstance(def);
                     Token tkn = pi.getRootToken();
                     tkn.signal();
                    etc, etc.
                  
                  ....
                  }








                  Hi,
                  appreciate your help!


                  One last question: I added the a key to ProcessInstance to help to obtain a specific ProcessInstance.
                  The ideia now is to obtain a list of pooled task associated with this ProcessInstance. How can I do this?
                  Here is my modified code



                  @Transactional
                       public String begin() {
                            GraphSession gs = jbpmContext.getGraphSession();
                            ProcessDefinition def = gs.findLatestProcessDefinition("buildProtocol");
                            
                            String processInstanceKey = "pik_" + idProject;
                            
                            ProcessInstance pi = jbpmContext.getProcessInstance(def, processInstanceKey);
                            if (pi == null) {
                                 pi = new ProcessInstance(def, null);
                                 pi.setKey(processInstanceKey);
                                 Token tkn = pi.getRootToken();
                                 tkn.signal();
                            } else {
                                 //TODO: Query for Pooled Task List associated with this Process Instance
                                 pi.resume();
                            }
                            return "/listActivities.xhtml";
                       }



                  Sorry for any inconvenience, this is my first project using JBPM.
                  Thanks!


                  • 6. Re: jBPM process does not start?
                    lvdberg

                    Hi,


                    There are different possibilities:



                    pi.getTaskMgmtInstance().getTaskInstances();
                    jbpmContext.getTaskList(actorId);


                    or you can get directly a list from a Seam managed bean, 


                    taskInstanceList
                    taskInstancePriorityList
                    taskInstanceListForType
                    pooledTaskInstanceList


                    You can download the free JBPM chapter of Seam in Action from the Manning.com website. It explains very good the possibilities of these beans.


                    Leo