1 2 Previous Next 20 Replies Latest reply on Jul 4, 2006 10:48 AM by goddam

    Process Instantiation

    goddam

      hello..
      i am trying to start a process execution by code.. that aparently is well done, because i had it from your examples...
      but.. the process don't start..
      this code..don't show any errors.. and runs ok..but the aprently it doesn´t do nothing to the process...

      can anybody give me a help here?


      code:

      public class instanciacao{
      static JbpmConfiguration jbpmConfiguration = null;

      static {


      jbpmConfiguration = JbpmConfiguration.parseXmlString(
      "<jbpm-configuration>" +

      // A jbpm-context mechanism separates the jbpm core
      // engine from the services that jbpm uses from
      // the environment.

      " <jbpm-context>" +
      " <service name='persistence' " +
      " factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
      " </jbpm-context>" +

      // Also all the resource files that are used by jbpm are
      // referenced from the jbpm.cfg.xml

      " <string name='resource.hibernate.cfg.xml' " +
      " value='hibernate.cfg.xml' />" +
      " <string name='resource.business.calendar' " +
      " value='org/jbpm/calendar/jbpm.business.calendar.properties' />" +
      " <string name='resource.default.modules' " +
      " value='org/jbpm/graph/def/jbpm.default.modules.properties' />" +
      " <string name='resource.converter' " +
      " value='org/jbpm/db/hibernate/jbpm.converter.properties' />" +
      " <string name='resource.action.types' " +
      " value='org/jbpm/graph/action/action.types.xml' />" +
      " <string name='resource.node.types' " +
      " value='org/jbpm/graph/node/node.types.xml' />" +
      " <string name='resource.varmapping' " +
      " value='org/jbpm/context/exe/jbpm.varmapping.xml' />" +
      "</jbpm-configuration>"
      );
      }



      public void inst (int i)
      {


      JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
      try {

      GraphSession graphSession = jbpmContext.getGraphSession();

      ProcessDefinition processDefinition =
      graphSession.findLatestProcessDefinition("ultima");

      ProcessInstance processInstance =
      new ProcessInstance(processDefinition);


      } finally {
      // Tear down the pojo persistence context.
      jbpmContext.close();


      }

      }
      }



      this line: " new ProcessInstance(processDefinition);"--> shouldn´t simply start the process choosed?

      what is missing?

      thanks..[ ]

        • 1. Re: Process Instantiation
          goddam

          MORE INFORMATION about the problem..

          well i made a process definition on the graphical designer toll..

          it has 3 nodes..

          -a start node;
          -a task node( to user bert)
          -a end node

          with the code int he example above i was expecting to start the process execution of the process ..and then the process automatically stops on the task...

          but when i go to the JBPM portal the user ernie.. does´nt have any task to do!!

          once again, can anybody help me?
          is something wrong on the code? because..it don´t appear any errors..

          thanks..

          • 2. Re: Process Instantiation
            kukeltje

            nowhere there is a use 'ernie' in you process. Why do you think he should have a task?

            and besides that, are you sure the hibernate config points to the same db in both cases (program and webapp)

            • 3. Re: Process Instantiation
              kukeltje

              btw, I missed something else (thank you david). It should be JbpmConfiguration.getInstance().createJbpmContext()

              Maybe that also makes a difference

              • 4. Re: Process Instantiation
                goddam

                Hi Ronald..thanks for your reply..
                I don´t know if you understand what i am trying to do..

                Here´s my more expecific explanation...:p:

                This is my process definition (done in jBPM designer toll), where you will see the task to be done by user "ernie"! Until here everything´s nice..the process is deployed..

                < process-definition
                xmlns="http://jbpm.org/3/jpdl" name="teste">
                < swimlane name="trabalho">
                < assignment expression="user(ernie)">
                < /swimlane>
                < start-state name="inicio">
                < transition name="" to="meio">
                < /start-state>
                < task-node name="meio">
                < task name="task1" swimlane="trabalho">
                < controller>
                < variable name="papel" access="read,write,required">
                < /controller>
                < /task>
                < transition name="" to="fim">
                < /task-node>
                < end-state name="fim"></end-state>
                < /process-definition>

                Now i have this code..(complete version), where i am trying to invoke the process.. and to make that when i go to the Webapp i have a new task to user(ernie):



                import java.io.Serializable;
                import java.util.ArrayList;
                import java.util.Collection;
                import java.util.Date;
                import java.util.HashMap;
                import java.util.Iterator;
                import java.util.List;
                import java.util.Map;

                import org.jbpm.db.*;
                import org.jbpm.graph.def.*;
                import org.jbpm.graph.exe.*;
                import org.jbpm.*;
                import org.jbpm.db.JbpmSession;
                import org.jbpm.db.JbpmSessionFactory;
                import org.jbpm.graph.def.DelegationException;
                import org.jbpm.graph.exe.Token;


                public class instanciacao{
                static JbpmConfiguration jbpmConfiguration = null;

                static {

                jbpmConfiguration = JbpmConfiguration.parseXmlString(
                "<jbpm-configuration>" +

                " <jbpm-context>" +

                " <service name='persistence' " +
                " factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
                " <service name='message' " +
                " factory='org.jbpm.msg.db.DbMessageServiceFactory' />" +
                " <service name='scheduler' " +
                " factory='org.jbpm.scheduler.db.DbSchedulerServiceFactory' />" +
                " <service name='logging' " +
                " factory='org.jbpm.logging.db.DbLoggingServiceFactory' />" +
                " <service name='authentication' " +
                " factory='org.jbpm.security.authentication.DefaultAuthenticationServiceFactory' />" +
                " <service name='persistence' " +
                " factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
                " </jbpm-context>" +

                " <string name='resource.hibernate.cfg.xml' " +
                " value='hibernate.cfg.xml' />" +
                " <string name='resource.business.calendar' " +
                " value='org/jbpm/calendar/jbpm.business.calendar.properties' />" +
                " <string name='resource.default.modules' " +
                " value='org/jbpm/graph/def/jbpm.default.modules.properties' />" +
                " <string name='resource.converter' " +
                " value='org/jbpm/db/hibernate/jbpm.converter.properties' />" +
                " <string name='resource.action.types' " +
                " value='org/jbpm/graph/action/action.types.xml' />" +
                " <string name='resource.node.types' " +
                " value='org/jbpm/graph/node/node.types.xml' />" +
                " <string name='resource.varmapping' " +
                " value='org/jbpm/context/exe/jbpm.varmapping.xml' />" +
                "</jbpm-configuration>"
                );
                }



                public void inst (int i)
                {


                JbpmContext jbpmContext = jbpmConfiguration.getInstance().createJbpmContext(); //how u tell me to do=)
                try {

                GraphSession graphSession = jbpmContext.getGraphSession();

                ProcessDefinition processDefinition =
                graphSession.findLatestProcessDefinition("teste");

                ProcessInstance processInstance =
                new ProcessInstance(processDefinition);

                jbpmContext.save(processInstance);



                } finally {

                jbpmContext.close();
                }
                }
                }


                sorry if this is a dum question but.. like this the hibernate config points..don´t are well done..for my final objective?

                Thanks..
                I will apriciate any help..
                maybe is something on the code..

                best regards[ ],
                pedro


                • 5. Re: Process Instantiation
                  kukeltje

                  you have to add a proceessInstance.signal() to get the process started. Read the documentation etc. to see examples of this.

                  • 6. Re: Process Instantiation
                    goddam

                    Hi Ronald.!!

                    thanks.. it works.. on the webapp the task appears on the user "bert"!
                    but it appears with one problem..
                    if i click on the task it appears the following error:


                    type Exception report

                    message

                    description The server encountered an internal error () that prevented it from fulfilling this request.

                    exception

                    javax.servlet.ServletException: Error calling action method of component with id _id1_1:_id4
                    javax.faces.webapp.FacesServlet.service(FacesServlet.java:109)
                    org.jbpm.webapp.filter.AuthenticationFilter.doFilter(AuthenticationFilter.java:55)
                    org.jbpm.web.JbpmContextFilter.doFilter(JbpmContextFilter.java:83)
                    org.jbpm.webapp.filter.LogFilter.doFilter(LogFilter.java:59)
                    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)


                    root cause

                    javax.faces.FacesException: Error calling action method of component with id _id1_1:_id4
                    org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
                    javax.faces.component.UICommand.broadcast(UICommand.java:106)
                    javax.faces.component.UIData.broadcast(UIData.java:338)
                    javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
                    javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
                    org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:271)
                    org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
                    javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
                    org.jbpm.webapp.filter.AuthenticationFilter.doFilter(AuthenticationFilter.java:55)
                    org.jbpm.web.JbpmContextFilter.doFilter(JbpmContextFilter.java:83)
                    org.jbpm.webapp.filter.LogFilter.doFilter(LogFilter.java:59)
                    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)


                    Do you know why this appears»?! is missing resolving this to work completely how i pretend..

                    thanks..
                    pedro

                    • 7. Re: Process Instantiation
                      goddam

                      ??

                      • 8. Re: Process Instantiation
                        goddam

                        HI!

                        Does anyone know why i have the error above?
                        i reaaly don´t understand

                        thanks...

                        • 9. Re: Process Instantiation
                          kukeltje

                          hmmm....one of the other topics where posts seem to be missing.

                          You have to look in the jbpm server logging to get more info. Usually there is more in there. Post the stacktrace here if you do not find an error there that you understand and we'll try to help.

                          • 10. Re: Process Instantiation
                            ssquare

                            Hi,

                            Glad to hear you were able to deploy the process programmatically.

                            I have the following issue when I try to do this. When I run the HelloWorlddBtest sample there is no error but I could not see any new process ("Hello world" is the process name) created in the HSQL.

                            Do I need to modify jBPM configuration? hibernate-cgf.xml?


                            thanks in advance

                            -Shiv

                            • 11. Re: Process Instantiation
                              kukeltje

                              please do not thread-jack. New problems should be posted in new threads.

                              • 12. Re: Process Instantiation
                                ssquare

                                Sure, I will start a new thread on the HelloworldDBtest.

                                However I have questions on the solution discussed in this thread.

                                (a) How to invoke this instanciacao class - from commandline or ant or eclipse?
                                (b) Also I wonder any changes required for the database configuration file?

                                Any additional details on the setup is much appreciated

                                -Shiv

                                • 13. Re: Process Instantiation
                                  kukeltje

                                  a) as you would any other application or class. Make sure it is a junit test or make sure it has a main
                                  b) any changes compared to what? I would think there are no chages needed, just configure it correctly for your db

                                  • 14. Re: Process Instantiation
                                    goddam

                                    Hi shiv and Ronald!

                                    Shiv:

                                    1 2 Previous Next