13 Replies Latest reply on Nov 6, 2013 5:30 AM by sudhabalu

    problem with JPAKnowledgeService and LocalTaskService

    ted.pan

      hi,

       

       

      When I use JPAKnowledgeService and LocalTaskService, the process won't continue when complete the 2nd Human Task.

       

       

      the following is the code fragment

       

       

       

       

      {code}


      Environment env = KnowledgeBaseFactory.newEnvironment();

      env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"));

      env.set( EnvironmentName.TRANSACTION_MANAGER,TransactionManagerServices.getTransactionManager());





      Properties properties = new Properties();

      properties.put("drools.processInstanceManagerFactory", "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");

      properties.put("drools.processSignalManagerFactory", "org.jbpm.persistence.processinstance.JPASignalManagerFactory");

      KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(properties);

      KnowledgeBase kbase = readKnowledgeBase();  -- read knowledgebase



      ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);



      EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task");

      org.jbpm.task.service.TaskService taskService = new org.jbpm.task.service.TaskService(emf, SystemEventListenerFactory.getSystemEventListener());



      LocalTaskService localTaskService = new LocalTaskService(taskService);

      LocalHTWorkItemHandler localHTWorkItemHandler = new LocalHTWorkItemHandler(localTaskService,ksession, OnErrorAction.RETHROW);

      localHTWorkItemHandler.setLocal(true);

      localHTWorkItemHandler.connect();

      ksession.getWorkItemManager().registerWorkItemHandler("Human Task", localHTWorkItemHandler);

      {code:java}

        • 1. Re: problem with JPAKnowledgeService and LocalTaskService
          swiderski.maciej

          the code above shows only bootstrap could you provide details on how you start process and then complete task?

           

          Note that both session and work item handler must be active when completing the task.

           

          HTH

          • 2. Re: problem with JPAKnowledgeService and LocalTaskService
            ted.pan

            Thanks Maciej,

             

            please find the attached files for the main program and the process definition I used.

             

             

             

            If I comment out the Line 94,

               ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);

             

            use

              ksession = kbase.newStatefulKnowledgeSession();

             

             

            the process works fine, but I do need the process instance persisted for future usage.

             

             

             

            Ted

            • 3. Re: problem with JPAKnowledgeService and LocalTaskService
              swiderski.maciej

              Just tried with simplified verion of your main class andvery simple process (start -> human task -> end) and everything works as expected process is triggered and completes successfully. See attached zip file. So I believe there must be some misconfiguration...

               

              HTH

              • 4. Re: problem with JPAKnowledgeService and LocalTaskService
                ted.pan

                hi Maciej,

                 

                Thanks again.

                 

                My problem is that I can not complete the second human task.

                 

                I adjust the process file you attached to 3 human tasks.

                 

                the 3rd human task could never be reached.  (in fact, I even added exit actions on second human task, the action is never be called, seems the second human task could not be completed).

                 

                 

                Ted

                • 5. Re: problem with JPAKnowledgeService and LocalTaskService
                  swiderski.maciej

                  attached is a test with three user tasks all completes without any problem. If you're running with spring it could be problem there...

                   

                  HTH

                  • 6. Re: problem with JPAKnowledgeService and LocalTaskService
                    ted.pan

                    hi Maciej,

                     

                    which version of jBPM and Drools you are using?

                     

                    I run the test2, it fails as well. i'm using jbpm 5.4.0.CR1 and Drools 5.5.0.CR1

                     

                     

                    Ted

                    • 7. Re: problem with JPAKnowledgeService and LocalTaskService
                      swiderski.maciej

                      I run on master. What you mean fail? what is the output when you run this test?

                      • 8. Re: problem with JPAKnowledgeService and LocalTaskService
                        ted.pan

                        hi Maciej,

                         

                        I got the following output

                         

                        WARNING: executing transaction with 0 enlisted resource

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        181    test    Reserved

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        182    test2    Reserved

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        WARNING: executing transaction with 0 enlisted resource

                        Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare

                        ...........( there are endless WARNING: executing transaction with 0 enlisted resource  Nov 2, 2012 12:32:35 PM bitronix.tm.twopc.Preparer prepare)

                         

                        for the master,  do you mean jBPM6.0 snapshot or jBPM5.4.0 snapshot?

                         

                        Thanks

                         

                        Ted

                        • 9. Re: problem with JPAKnowledgeService and LocalTaskService
                          swiderski.maciej

                          master is 6.0: here is the output when running it:

                           

                          log4j:WARN No appenders could be found for logger (bitronix.tm.resource.jdbc.PoolingDataSource).
                          log4j:WARN Please initialize the log4j system properly.
                          log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
                          Loading knowledge base.
                          
                          Registering Human Task..
                          
                          1    test    Reserved
                          2    test2    Reserved
                          3    test3    Reserved
                          
                          
                          Process is null
                          Fri Nov 02 18:09:26 CET 2012    Process completed?
                          

                           

                          Will try to give it a try on 5.4.0 CR1 as soon as I can and let you know.

                           

                          HTH

                          • 10. Re: problem with JPAKnowledgeService and LocalTaskService
                            ted.pan

                            hi Maciej,

                             

                             

                            I made a mistake when run the tests you provided. I didn't change the persistence.xml to point to the right database( the one created on-the-fly)

                             

                            After I fixed this issue, I tried the test again with jbpm5.4.0.CR1 and jbpm6.0.0.SNAPSHOT( today's).

                             

                            And I add script to the exit actions of each human task

                             

                             

                            I got the same result: ( the main process does stop. but no log for the third human task)

                            task #1

                            System.out.println("leaving human task 1");   

                            task #2

                            System.out.println("leaving human task 2");

                            task #3

                            System.out.println("leaving human task 3");

                             

                            from the following log, the "leaving human task 2" is not shown.

                             

                             

                            Nov 2, 2012 1:56:47 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Registering Human Task..

                            Nov 2, 2012 1:56:47 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:56:47 PM org.jbpm.task.identity.UserGroupCallbackManager setCallback

                            INFO: UserGroupCallback registered: org.jbpm.task.identity.DefaultUserGroupCallbackImpl

                            Nov 2, 2012 1:56:48 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:56:51 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:56:51 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            1    test    Reserved

                            Nov 2, 2012 1:56:57 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:56:57 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:56:57 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:56:57 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:56:57 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            leaving human task 1

                            Nov 2, 2012 1:56:57 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:56:57 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:57:00 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:57:00 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            2    test2    Reserved

                            Nov 2, 2012 1:57:00 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:57:00 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:57:00 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:57:00 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:57:00 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:57:00 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:57:00 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Nov 2, 2012 1:57:00 PM bitronix.tm.twopc.Preparer prepare

                            WARNING: executing transaction with 0 enlisted resource

                            Process is WorkflowProcessInstance1 [processId=HumanTask,state=1]

                            Fri Nov 02 13:57:00 EDT 2012    Process completed?

                             

                             

                             

                            So I think the problem may be with my configuration. I attach all the files I need, could you help me to figure it out?

                             

                            Thanks

                             

                            Ted

                            • 11. Re: problem with JPAKnowledgeService and LocalTaskService
                              ted.pan

                              hi,

                               

                              Just to keep this topic updated to prevent others wasting time, I would like to report my progress back here.

                               

                              The problem is with the persistence.xml.   When I change back to use JPA1, everything works fine.

                               

                              I will do more investigation to see if the problem is with JPA2 or is with my JPA2's persistence.xml

                               

                               

                              Thanks

                               

                              Ted

                              • 12. Re: problem with JPAKnowledgeService and LocalTaskService
                                jbize

                                Hey Ted,

                                 

                                I think your JBPMorm-JPA2.xml looks ok, what does your Taskorm.xml look like? There have been issues there in the past, could your problem be related?  (Just grasping.)

                                 

                                Oh, and I was just looking at the 5.2.0.Final source of the ProcessInstanceInfo entity, and it looks properly annotated for javax.persistence.  Is the extra entity mapping in XML really required?

                                 

                                John

                                • 13. Re: problem with JPAKnowledgeService and LocalTaskService
                                  sudhabalu

                                  Hi Ted,

                                   

                                  Did you found solution for this problem? Am also facing same issue when using LocalTaskService and JPAKnowledgeService.