6 Replies Latest reply on Jan 30, 2006 9:05 PM by vballarta

    example of create process instance, please!!

    katador

      Hello,

      I found for all web and can't find one example of how create a process instance, how i do??? i found here a piece of code but this doesn't work.

      Please any charitable soul can post any code please...??? on documentation doesn't have usefull examples.

      thanks in advance.

      ktdr

        • 1. Re: example of create process instance, please!!
          enazareno

          Hi,

          Before you can create a process instance, you need to have a process definition deployed. So I think, the first step that you need to do is deploy a process defintion correctly. Once you have the process defintion deployed, you can already start creating process instances for that. To track a process instance you need to keep hold of the process instance id so you will be able to retrieve it if you may need to re-signal it.

          Regards,

          Elmo

          • 2. Re: example of create process instance, please!!
            katador

            Hello,

            Thanks for your answer. I've once process definition deployed. i do with eclipse.

            and now, i'm trying of create the program for execute, i want do it from a bean, and i don't understan how take a definition process because, i found three ways:

            - using a parsexml... where i pass a string like "myprocess.par/processdefinition.xml" , this way, i think works when had the definition file in the same package of my class, it's right this?

            - getting a list of definition process deployed, with a graph session, but here need jbpm.properties in the package, yes??

            - or using ProcessDefinition method, what this need a parameter (i don't remember now which it's).

            before this, it's necesary begin a jbpmsession with the method with the same name, and then can use ProcessInstance, at which can receive by parameter a ProcessDefinition object).

            It's right this steps?? how can i take the process definition what i want exec?
            some it'smissing? if you have a example, a lot of persons will be very gratefull :D

            thanks in advance!!

            Katador.

            • 3. Re: example of create process instance, please!!
              enazareno

              Hi,

              If you are using jbpm 3.1beta here is a sample code:

              JbpmConfiguration config = JbpmConfiguration.getInstance();
              JbpmContext ctx = config.createJbpmContext();
               try {
               ProcessDefinition def = ProcessDefinition.parseXmlString(xml);
               ctx.deployProcessDefinition( def);
               }
               catch (Exception e) {
               return "FAILED: " + e.getMessage();
               }
               finally {
               ctx.close();
               }
              


              If you are using jbpm3.02, etc, pls. let me know. It is quite different. Also indicate what database you're using and what environment (servlets? Jboss? ).

              Regards,

              Elmo

              • 4. Re: example of create process instance, please!!
                katador

                Hello,
                Thanks Elmo for your answers, i'm using jbpm 3.0.2, because when download, don't see link for beta version, have important improvements?.

                About the code, the xml variable, you say what i must pass the xml of definition process?? or this variable have a value obtained from other statement and this code it's for deploy a process definition? because according to eclipse deploy it's ok, but looking the hsqldb from database manager, this appear in jbpm_processdefinition

                i'm using postgresql, because i set with jbpm.db the hibernate.properties and change hibernate.cfg.xml, but continue using hsql jbpm, but this not it's urgent like correct deploy and create the process instance

                1 websale 1 true 1
                2 null -1
                3 null -1

                and in postgresql it's empty :S

                i hope that give you any clue of my problems :)

                thanks in advance.

                Arturo

                • 5. Re: example of create process instance, please!!
                  enazareno

                  Hi,

                  The xml variable refers to the process definition string form

                   String xml = "<process-definition name='x'>...</process-definition>";


                  I suggest first deploying process definition this way cos for me it is the easiest way. When you have done this, then you can deploy the definition using pars if you want to experiment other methods of deployment. There is even a built-in servlet that does this for you.

                  If you're using postgresql, check that the tables must be created after deployment. There must be an entry in jbpm_processdefinition. If there is none, then your problem is jbpm is still using hsqldb. If you see an entry in the table, then you are in the right track.

                  BTW, are you working in eclipse? Have you created the tables successfully in postgresql?

                  Regards,

                  Elmo

                  • 6. JBPM with Postgres
                    vballarta

                    Please someone who knows how install JBPM 3.0.2 with Postgres 8.0 Let me Know how are the steps?i have install jbpm-starters-kit-3.0.2

                    Thanks