8 Replies Latest reply on Mar 24, 2014 10:23 AM by Ramesh Routray

    Going from jBPM5 demo to full fledged application - completely confused

    Craig St. Jean Newbie

      I am completely confused, hoping someone can help.  I've installed the demo, and have created a test project using persistence and human tasks.  This works ok (had a lot of issues when deploying to the JBoss setup from install.demo, but whatever).  Now I want to start actually creating an application.

       

      Here is our use case for a workflow engine - we want to have custom applications that will leverage the various APIs, especially human tasks.  We do not have any desire to run things like the jBPM Console, Forms, etc. -- everything will be managed via our applications.  We are using WebSphere AS 7 and Oracle RAC.

       

      Can someone tell me or point me in the right direction:

      • What all do I need to deploy to our application server given that we do not want the bundled GUI based applications, unless required for API based functionality?
      • Is there a DDL for the tables to be created?  In our environment we most definitely do not run applications with DDL access so we must provide the DDLs to the DBAs
      • Does jBPM5 require JPA 1 or JPA 2?
      • Running the demo it looks like it spins up HornetMQ.  Is this required or just part of the demo?  Preferably no MQ provider would be involved, but if one is then it must be WebSphere MQ -- is this a problem?
      • How do we deploy workflow projects to jBPM?  Is this what Guvnor is for?  Does Guvnor work with WebSphere and what is its required DDL?
      • Based on our use case, are we looking at the wrong tool for the problem?

       

      Thank you!

        • 1. Re: Going from jBPM5 demo to full fledged application - completely confused
          Maciej Swiderski Master

          Craig St. Jean wrote:

           

          I am completely confused, hoping someone can help.  I've installed the demo, and have created a test project using persistence and human tasks.  This works ok (had a lot of issues when deploying to the JBoss setup from install.demo, but whatever).

           

          if you could post some details on what sort of problems you had it would be very useful to try to fix those to make sure other won't face it anymore.

          Craig St. Jean wrote:

          • What all do I need to deploy to our application server given that we do not want the bundled GUI based applications, unless required for API based functionality?

          then you should only rely on the actual libraries (jbpm, drools and their dependencies) take a look at the jbpm-installer/runtime folder where you find all of these. Please not that depending on what you use from jbpm you won't need all of these libraries but I believe that is a good start and then try to strip it from what is not needed. web applications are completely optional.

          Craig St. Jean wrote:

          • Is there a DDL for the tables to be created?  In our environment we most definitely do not run applications with DDL access so we must provide the DDLs to the DBAs

          unfortunately in v5 there were no DDL scripts provided although in 5.4 there are ant targets to produce such DDL scripts based on persistence.xml these targets are jbpm.schemaexport, humantask.schemaexport. In general it relies on Hibernate Tools so it can be done with eclipse plugin as well, depending on what you prefer. In v6 there will be DDL scripts provided out of the box.... so slightly improved.

           

          Craig St. Jean wrote:

          • Does jBPM5 require JPA 1 or JPA 2?

          it supports both but recommended to use JPA2 especially when running on AS7 where hibernate 4(JPA2) is provided by default.

           

          Craig St. Jean wrote:

          • Running the demo it looks like it spins up HornetMQ.  Is this required or just part of the demo?  Preferably no MQ provider would be involved, but if one is then it must be WebSphere MQ -- is this a problem?

          HornetQ was used by default for runtime engine to human task communication but this is just one of several options available. In your case the best would be to go with local task service that first of all does not involve any communication protocol and second of all, participates in same transaction as runtime engine. Please not that LocalTaskService is not thread safe. WebSphere MQ might be used as well but it would need to be configured with JMS support for human task service.

           

          Craig St. Jean wrote:

           

          • How do we deploy workflow projects to jBPM?  Is this what Guvnor is for?  Does Guvnor work with WebSphere and what is its required DDL?

          Guvnor is the repository and it can be used to provide process definition (and not only processes) to the runtime engine. However, console uses KnowledgeAgent to connect to guvnor and read what is available. Same concept can be used within your custom application as KnowledgeAgent provides flexible definition of where to find assets - directory, URL, etc. So it's pretty much up to you how you are going to deliver the assets for execution, you can even precompile the KnowledgeBase and the read the packages directly. Guvnor can run on WebSphere as far as I know.

           

          Craig St. Jean wrote:

          • Based on our use case, are we looking at the wrong tool for the problem?

          this is exactly why jBPM is built for. So the case you describes can be covered with jBPM especially that human task is well defined by WS-HT spec so you know what is available. And the last but not least is the community that is always eager to help out

           

          HTH

          • 2. Re: Re: Going from jBPM5 demo to full fledged application - completely confused
            Craig St. Jean Newbie

            Maciej Swiderski wrote:

             

            if you could post some details on what sort of problems you had it would be very useful to try to fix those to make sure other won't face it anymore.

            I had a lot of strange issues such as:

            • Logging into the jBPM Console after having logged in once before the page would be only partially rendered.  I had to restart JBoss to fix
            • Trying to pull up any forms just resulted in an error page
            • Eclipse would not retrieve any of the Human Tasks when using start.demo

            In the end I just stopped JBoss and ran through the Eclipse with the JBPMHelper.startTaskService() uncommented

             

            MAC-3030:jbpm-installer() $ java -version
            java version "1.7.0_21"
            Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
            Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
            MAC-3030:jbpm-installer() $ uname -a
            Darwin MAC-3030.local 12.5.0 Darwin Kernel Version 12.5.0: Mon Jul 29 16:33:49 PDT 2013; root:xnu-2050.48.11~1/RELEASE_X86_64 x86_64
            

             

            Maciej Swiderski wrote:

             

            then you should only rely on the actual libraries (jbpm, drools and their dependencies) take a look at the jbpm-installer/runtime folder where you find all of these. Please not that depending on what you use from jbpm you won't need all of these libraries but I believe that is a good start and then try to strip it from what is not needed. web applications are completely optional.

            Thank you, from the documentation I was reading that part was not clear to me.

             

            Maciej Swiderski wrote:

             

            unfortunately in v5 there were no DDL scripts provided although in 5.4 there are ant targets to produce such DDL scripts based on persistence.xml these targets are jbpm.schemaexport, humantask.schemaexport. In general it relies on Hibernate Tools so it can be done with eclipse plugin as well, depending on what you prefer. In v6 there will be DDL scripts provided out of the box.... so slightly improved.

            Perfect, I updated the files in db and ran "ant jbpm.schemaexport" and "ant ht.schemaexport".  Another thing I could not find in the documentation...

             

            Maciej Swiderski wrote:

             

            it supports both but recommended to use JPA2 especially when running on AS7 where hibernate 4(JPA2) is provided by default.

            We will be using WebSphere 7.0 without the JPA2/OSGi feature pack.  I will try to report back after I get a working copy using JPA1 (which has always been a struggle to perfect in the past).

             

            Maciej Swiderski wrote:

             

            HornetQ was used by default for runtime engine to human task communication but this is just one of several options available. In your case the best would be to go with local task service that first of all does not involve any communication protocol and second of all, participates in same transaction as runtime engine. Please not that LocalTaskService is not thread safe. WebSphere MQ might be used as well but it would need to be configured with JMS support for human task service.

            Turns out I was looking at the 5.2 documentation, which only mentioned Mina and HornetMQ.  The 5.4 documentation (http://docs.jboss.org/jbpm/v5.4/userguide/ch.human-tasks.html) does reference the local task service, but doesn't really explain much.  The documentation on starting the local task service (http://docs.jboss.org/jbpm/v5.4/userguide/ch.integration.html#d0e7902) also doesn't nor does the JavaDocs (http://docs.jboss.org/jbpm/v5.4/javadocs/org/jbpm/task/service/local/LocalTaskService.html).  Where can I find information on the implications of using the local task service?  Does it start up new threads (WebSphere would not like this) or just run in the local transaction manager?

             

            Maciej Swiderski wrote:

             

            Guvnor is the repository and it can be used to provide process definition (and not only processes) to the runtime engine. However, console uses KnowledgeAgent to connect to guvnor and read what is available. Same concept can be used within your custom application as KnowledgeAgent provides flexible definition of where to find assets - directory, URL, etc. So it's pretty much up to you how you are going to deliver the assets for execution, you can even precompile the KnowledgeBase and the read the packages directly. Guvnor can run on WebSphere as far as I know.

            This makes much more sense now that you mentioned the web applications are not required and I can just use the JARs.

             

            I guess my biggest issue is that looking at everything involved in the demo is very overwhelming, and documentation to go from that to an application using jBPM for workflow seems to be a bit lacking.  The user guide seems like a good reference if you already know what to look for...

             

            Thank you!!

            • 3. Re: Going from jBPM5 demo to full fledged application - completely confused
              Craig St. Jean Newbie

              Well, after a bit of struggle, I've managed to get a mostly working sample project together.  It's a basic hotel interaction process:

               

              • Customer Requests Room
              • Clerk Looks for Rooms
              • A script returns a room number, or a default if no rooms
              • If no rooms, Clerk Tells Customer No Rooms
              • If there was a room, Clerk Gives Room Number
              • End

               

              The project uses:

               

              • jBPM 5.4
              • WebSphere Application Server 7.0
              • JPA 1
              • Oracle
              • Spring MVC

               

              Is there any chance you (or someone else) could take a look at it to see if its being done in the right way?  I noticed a lot of people trying to use WAS 7 in this way had unanswered questions, this project could hopefully help them out.  https://github.com/craigstjean/jBPM-WAS7-Spring-Sample

               

              The only thing that I need to figure out right now is why when a user completes a task it does not move onto the next step.

               

              Thank you!

              • 4. Re: Going from jBPM5 demo to full fledged application - completely confused
                Maciej Swiderski Master

                Craig, nice to hear you moved forward with this. I'll take a look at the github repo and let you know if I have any comments.

                 

                As it comes to the user task to moving the process forward it is most likely caused by human task work item handler is not registered on ksession or it is not connected to task service and thus does not receive notification events when task is completed.

                 

                HTH

                • 5. Re: Going from jBPM5 demo to full fledged application - completely confused
                  Craig St. Jean Newbie

                  Maciej,

                   

                  I have figured out how to get the solution working and have updated on GitHub, though I would be more than appreciative if you could review it and possibly answer some of my "Questionable Items" in the README.

                   

                  Thank you!

                  • 6. Re: Going from jBPM5 demo to full fledged application - completely confused
                    Maciej Swiderski Master

                    Craig, thanks for reminding me about this, quite few things to do now

                     

                    Went through the code and it looks really good, simple and compact implementation - good job! Few minor comments below:

                    • process definition (bpmn2) looks like you have duplicated item definitions as I can only see tw process variables (properties) might be worth to clean up
                    • JbpmServiceImpl - not sure you are aware but you use in memory ksession so in case of server restart you will loose the process state but user tasks will be there, here you create ksession directly from kbase while you should use JPAKnowledgeService to create or load ksession.
                    • JbpmServiceImpl you should not cache Environment instances as every ksession must have its own Environment otherwise you'll make the ksession not thread safe
                    • JbpmServiceImpl good you create local task service for every call to getTaskService while the actual TaskService is created only once that should prevent of thread safety issues when using LocalTaskService
                    • RoomResolverImpl assuming this is a sort of a service then putting it as process variable is not best way, I would say you should use service task for invoking it and then only evaluate results. Alternatively you could employ business rules here that will actually be responsible for checking the availability of the rooms and then rest of the process can rely on that evaluation.With service task you can directly call java class and with rules the service should be there like a global while all rooms should be inserted as facts.

                     

                    Regarding your questions thread safety and room resolver was already mentioned, process variables should be set at the beginning and then you can use output mapping to set process variable with result of activity execution. Like you would ask clerk to actually put the value into the process flow using some sort of a form. That value then can be set as process variable using output mapping. I noticed you use script task for it while it works it gives bit of technical information into the actual business process so encapsulating it as service task with output mapping might be better choice.

                     

                    HTH

                    • 7. Re: Going from jBPM5 demo to full fledged application - completely confused
                      Craig St. Jean Newbie

                      Thank you!  I have made all of the updates, including using Service Tasks.

                       

                      One issue that I did have though was while using the ContainerManagedTransactionManager (since I'm using WebSphere), Hibernate was throwing exceptions on setRollbackOnly.  I had to create a copy of org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform and modify it for my hibernate.transaction.jta.platform, based on the code https://forum.hibernate.org/viewtopic.php?uid=70595&f=1&t=992310&start=0 (for WAS 8, Hibernate 4).  Not a jBPM issue, hopefully Hibernate gets it fixed sometime.

                      • 8. Re: Going from jBPM5 demo to full fledged application - completely confused
                        Ramesh Routray Newbie

                        Hi Craig/swiderski.maciej,

                         

                        I have downloaded your project and imported in eclipse. I am using: eclipse Juno SR1, WAS 7, Oracle 10g. I followed your steps mentioned in github.

                        While publishing the project, I am getting the following error.

                        Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 27 in XML document from ServletContext resource [/WEB-INF/spring/application-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jbpm:kbase'.

                         

                        After getting the error, I tried to modify the line in application-context.xml:
                        http://drools.org/schema/drools-spring http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring.xsd

                        downloaded the XSD file and provided as a local copy in the same (spring) folder.

                        http://drools.org/schema/drools-spring drools-spring.xsd

                        Still I am getting the same error.

                        If I modify as below, I get compilation error in application-context.xml:

                        http://drools.org/schema/drools-spring http://drools.org/schema/drools-spring.xsd

                         

                        Could you please help me get rid of this?

                         

                        Thanks!