2 Replies Latest reply on Jul 7, 2014 5:35 PM by cgwang1992

    Business Rules, Service Tasks in one process (Beginner)

    cgwang1992

      Hi everyone!

       

      I have been scouring the forums and website for the past week and trying to work my way through some simple projects involving processes and finally decided to create an account and just ask my questions.

      I am very new to this technology so there is still a lot I do not understand.

       

      I have a few questions:

      1. Some sample projects suggest that I create a runtime environment and runtime manager, knowledge sessions and then add in the .bpmn files as part of the resource while others go straight into creating the builders, making the sessions and adding the process without ever building an environment first. I was wondering why there were two approaches to this and if one is more efficient than the other? I am confused because they both seem to create the session and start my process. And, what is the best method for me to execute my process from now on?

       

      2.

      I have gone through the jbpm 6.0 manual online and have read up on simple examples and have added an work item using a wid file and a drools configuration file in the META-INF folder. I was wondering where I am find an example of adding a workItem (or ServiceTask) not in a declarative way but rather through code? So that my work is checked at runtime rather than at compile time. i.e creating a work item and registering that with my process and work item handler. I cant find a good example on this.

       

      3.

      I currently have RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultInMemoryBuilder().addAsst(ResourceFactory.newClassPathResource("com.sample.bpmn"), ResourceType.BPMN2).get(); to load up my process that I created.

      How would I add in a second resource into this environment? I have a rules file .newRules.drl that I would like to incorporate into a business rules node in my process sample.bpmn but I cannot find a good example of where to begin.

       

      In a nut shell, I am looking to touch the process flow as little as possible and manipulate everything through code and I am looking for a medium-level example to guide me. Any suggestion is greatly appreciated!

      I understand these questions are basic but I have been searching for a few days now and I am disappointed at the progress I have made and was hoping to look for help.

       

      Thank you!

       


        • 1. Re: Business Rules, Service Tasks in one process (Beginner)
          swiderski.maciej

          Charlie Wang wrote:

           

          Hi everyone!

           

          I have been scouring the forums and website for the past week and trying to work my way through some simple projects involving processes and finally decided to create an account and just ask my questions.

          I am very new to this technology so there is still a lot I do not understand.

           

          I have a few questions:

          1. Some sample projects suggest that I create a runtime environment and runtime manager, knowledge sessions and then add in the .bpmn files as part of the resource while others go straight into creating the builders, making the sessions and adding the process without ever building an environment first. I was wondering why there were two approaches to this and if one is more efficient than the other? I am confused because they both seem to create the session and start my process. And, what is the best method for me to execute my process from now on?

           

          use runtime environment and runtime manager from version 6. Builders and direct creation of session was the way to work in version 5. version 6 sets up much more things for you automatically while with builders you need to know all the low level details to create same thing. Both will produce same results but runtime manager approach is easier to use.

           

          Charlie Wang wrote:

           

          2.

          I have gone through the jbpm 6.0 manual online and have read up on simple examples and have added an work item using a wid file and a drools configuration file in the META-INF folder. I was wondering where I am find an example of adding a workItem (or ServiceTask) not in a declarative way but rather through code? So that my work is checked at runtime rather than at compile time. i.e creating a work item and registering that with my process and work item handler. I cant find a good example on this.

          from runtime point of view you need only to register handler for your custom work item handlers and this is done by use of RegisterableItemsFactory on runtime environment.  Take a look at this test case (and others in that folder) to find more usage scenarios.

           

          Charlie Wang wrote:

           

          3.

          I currently have RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultInMemoryBuilder().addAsst(ResourceFactory.newClassPathResource("com.sample.bpmn"), ResourceType.BPMN2).get(); to load up my process that I created.

          How would I add in a second resource into this environment? I have a rules file .newRules.drl that I would like to incorporate into a business rules node in my process sample.bpmn but I cannot find a good example of where to begin.

          same way ad you added your first asset, just use another addAsset method after first one.

           

          HTH

          • 2. Re: Business Rules, Service Tasks in one process (Beginner)
            cgwang1992

            Thank you for your reply Maciej!

             

            1. I was also wondering if you could give me a good example or explanation on how persistence is achieved in jbpm? Specifically how it combs together with the EntityManagerFactory and the RuntimeEnvironment that I have already set up. I have read the chapter 8 tutorial and a variety of videos but can't seem to get good jump start and how it all ties in with the H2 database and the Jboss AS 7. I am currently running into an error in my persistence.xml that i am unable to build EntityManagerFactory in my PersistenceUnit: org.jbpm.persistence.jpa at org.hibernate.ecj.EJb3Configuration.bulidEntityManagerFactory, I will post the rest of the code here. I have the server up and running and created a user for it but I do not understand how to configure the database from here.

             

            2. I followed your pointer for adding the rules file into my runtime environment with a second addAsset and it worked great! Which leads me to ask if I have a Business Rules node within my process workflow, how do I link this specific .drl file to this specific node?

            Right now when my ksession runs my process I simply insert an object and add the rules file to my classpath and it executes, but it does not execute in order of my work flow.

             

            Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityManagerFactory

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:930)

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)

                at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:72)

                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)

                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)

                at com.sample.Main.main(Main.java:75)

            Caused by: org.hibernate.service.jndi.JndiException: Unable to lookup JNDI name [jdbc/jbpm-ds]

                at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:68)

                at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:116)

                at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)

                at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)

                at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)

                at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)

                at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:78)

                at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2295)

                at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2291)

                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1760)

                at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:920)

                ... 5 more

            Caused by: javax.naming.NameNotFoundException: unable to find a bound object at name 'jdbc/jbpm-ds'

                at bitronix.tm.jndi.BitronixContext.lookup(BitronixContext.java:83)

                at bitronix.tm.jndi.BitronixContext.lookup(BitronixContext.java:67)

                at javax.naming.InitialContext.lookup(InitialContext.java:415)

                at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:65)

                ... 20 more

              <persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA">

             

             

             

            Thanks you in advance for your expertise!