11 Replies Latest reply on Jan 25, 2006 12:13 AM by Ravi Prakash Reddy Ummadi

    jbpm in a web application

    lavanya sripada Newbie

      Hi,

      I am very new to jbpm(and bpm in general), with tomcat + mysql(thanks to the forums) got jbpm installed and the sample websale application works perfectly fine.

      So basically i need to use jbpm in a web application. Here is my idea, please correct me if I am wrong :
      In my web-application include jbpm.jar as a library, and create jbpmsessions, processinstances etc. using the apis.

      1. But then about the database, shold the jbpm db tables be created in the same database as the web applications?
      2. how will jbpm know the database properties, does it look in hibernate.cfg.xml(I am also relatively new to hibernate)?
      3. How are the pars deployed on Tomcat ?
      4. How much does my web application need to know bout jbpm? for example: say a process is in a particular state, when some even triggers it to the next state/node how do the web application and jbpm work together?

      Can anyone guide me with these questions, any help is appreciated!

        • 1. Re: jbpm in a web application
          Ravi Prakash Reddy Ummadi Newbie

          >In my web-application include jbpm.jar as a library, and create jbpmsessions, processinstances etc. using the apis.

          CORRECT

          > 1. But then about the database, shold the jbpm db tables be created in the same database as the web applications?

          YOU CAN CREATE A NEW DATABASE SAY 'JBPMDB' AND EXECUTE THE SCRIPT PROVIDED IN THE PACKAGE JBPM-DB.

          >2. how will jbpm know the database properties, does it look in hibernate.cfg.xml(I am also relatively new to hibernate)?

          YES. IT LOOKS HIBERNATE.CFG.XML. THIS XML HAS TO BE IN THE CLASSPATH (WEB-INF/CLASSES)

          > 3. How are the pars deployed on Tomcat ?

          > 4. How much does my web application need to know bout jbpm? for example: say a process is in a particular state, when some even triggers it to the next state/node how do the web application and jbpm work together?

          YOUR WEB APP NEEDS TO CALL JBPM API WHEN REQUIRED

          Can anyone guide me with these questions, any help is appreciated!

          • 2. Re: jbpm in a web application
            Mennen Newbie

            i'm a also a newbie to jbpm,

            You talked about jbpm sessions, where can I find them?

            THanks

            • 3. Re: jbpm in a web application
              lavanya sripada Newbie

              I understand in hibernate the default config file is hibernate.cfg.xml, but a different file can also be used. Can that work with jbpm.

              also just to clarify, will jbpm tables and the webapp tables exist in the same database?

              to access a particular process instance, do i have a process id or something to the apis? I mean does the webapp need to know the id of say a particular process instance or token to access it?


              It will be a great help if i have these questions answered.
              Thanks in advace!

              • 4. Re: jbpm in a web application
                Alejandro Guizar Master

                 

                "mennen" wrote:
                You talked about jbpm sessions, where can I find them?

                "lappi_79" wrote:
                do i have a process id or something to the apis

                Please take a look at the database example studied in section 3.2 of the jBPM user guide. It shows how to use jBPM's persistence API to save and load process objects.


                • 5. Re: jbpm in a web application
                  Alejandro Guizar Master

                   

                  "lappi_79" wrote:
                  the default config file is hibernate.cfg.xml, but a different file can also be used. Can that work with jbpm

                  Yes. You can use your own hibernate configuration file. You can either put your hibernate.cfg.xml in the root of your classpath or specify an alternate resource name in the jBPM configuration file; see Configuration files.

                  The jBPM tables and your own tables can coexist if you reference both sets of mappings from your configuration file.

                  • 6. Re: jbpm in a web application
                    lavanya sripada Newbie

                    Hi Alex,

                    Thanks for replying, both posts were very helpful.
                    I have some more doubts

                    in section 3.2 example it says :

                    // Now, we search for all process instances of this process definition.
                     List processInstances =
                     graphSession.findProcessInstances(processDefinition.getId());
                    
                     // We know that in the context of this unit test there is
                     // only one execution. In real life, the processInstanceId can be
                     // extracted from the content of the message that arrived or from
                     // the user making a choice.
                     ProcessInstance processInstance = (ProcessInstance) processInstances.get(0);


                    in real life we might not go for processInstances.get(0),
                    can you give me a code sample of how to resolve a particular process instance from the given list. Like what is the identifier?

                    Thanks in advance!

                    • 7. Re: jbpm in a web application
                      Ravi Prakash Reddy Ummadi Newbie

                      Even in real life you need to keep track of processinstanceID or taskInstanceID to access process instances.

                      given processInstanceID, you can access processInstacnce object using the folloiwng code.

                      JbpmSession session = JbpmSessionFactory.getInstance().openJbpmSession();
                      ProcessInstance proc = session.getGraphSession().loadProcessInstance(id);

                      - Ravi Prakash

                      • 8. Re: jbpm in a web application
                        Ravi Prakash Reddy Ummadi Newbie

                        Even in real life you need to keep track of processinstanceID or taskInstanceID to access process instances.

                        given processInstanceID, you can access processInstacnce object using the folloiwng code.

                        JbpmSession session = JbpmSessionFactory.getInstance().openJbpmSession();
                        ProcessInstance proc = session.getGraphSession().loadProcessInstance(id);

                        - Ravi Prakash

                        • 9. Re: jbpm in a web application
                          abdessamad abouti Newbie

                          hi,
                          i want to develop a JBPM web application like the sample websale, i want to know how to generate the script of the database from the processdefinition.xml, how can i do it?
                          thanks

                          • 10. Re: jbpm in a web application
                            lavanya sripada Newbie

                            Thanks for your help Ravi Praksah, Things are getting much clearer now.

                            One more question, TansInstances can be assigned to actors(java.lang.String). Does jbpm need to know the user before hand, like there is a jbpm_id_user table, is that a jbpm table or websale app table?
                            cos as it is there will be a user table in any web app, having another copy with jbpm would be duplication. I mean does userid just mean a string or a foregn key or some other association exist?

                            Second thing, if down the process there is a task that needs to be performed by multiple people can it be achieved by creating multiple task instances?

                            I assume the task instance id also needs to be remembered by the webapp.

                            am I thinking on the right lines.
                            Thanks!

                            • 11. Re: jbpm in a web application
                              Ravi Prakash Reddy Ummadi Newbie

                              I don't know how exactly the websale application generated the sql script from process definition. But here is a solution I can define.

                              1. deploy process definition into database using the regular code.

                              
                              
                               ProcessDefinition def = ProcessDefinition.parseXmlString( "<process-definition ...");
                               JbpmSession session =
                               JbpmSessionFactory.getInstance().openJbpmSession();
                               session.beginTransaction();
                               session.getGraphSession().saveProcessDefinition(def);
                               session.commitTransactionAndClose();
                               System.out.println( "FINISH DEPLOYMENT" );
                              
                              


                              2. After this your database will have the tables filled with process definition entries. Just take a dump of the database.

                              This is just a work around to get the script. Let us know if you find a better way.

                              -Ravi Prakash