6 Replies Latest reply on Dec 4, 2012 4:39 PM by Prabakar Singaram

    JPBM persistence and transaction Questions

    Prabakar Singaram Newbie



      I have some questions based on my understanding, please correct me if I am wrong, If I am right please guide me through my questions...thanks in advance...


      My Understanding:

      task (taskid, session id) is belongs to process (process id , session id), task no longer valid without process reference (I am talking about persistence in JBPM)


      My questions?

      1. Do we really need separate persistence.xml file for each humantask persistence and process persistence?

      2. Why there is a two types of transaction used in this persistence (like  JTA-process, resource local for - task)?

      3. Is it possible to create one persistence.xml file to handle JBPM persistence (both process and humantask)?

      4. Do I need two schema (one for process table and one for task tables)?


      kindly invite you all to participate in this discussion...



        • 1. Re: JPBM persistence and transaction Questions
          Mauricio Salatino Master

          I'm not sure to understand "your understanding".. you will need to elaborate more..

          About your questions:


          1) No you can have just one Persistence Unit and use the Local Task Service

          2) If you use just one Persistence Unit you don't need to care about that.. JTA or Resource Local are for cordinating more than one Transactional Resourece inside the same transaction

          3) Yes

          4) no, it's up to you, you can use just a single schema..



          1 of 1 people found this helpful
          • 2. Re: JPBM persistence and transaction Questions
            Prabakar Singaram Newbie

            Thanks Mauricio Salantino,


            What my understanding is ...

            a humantask defined inside the process, human task node is one of the node in the process flow, So every humantask belongs to one or more process flow. so the relatiship between human task and the process defined using the process id and task id. So when we store the process information in the database we can store the task information also in the same databse. So my final comment is all can handle in on epersintence unit using one schema. but the example and some jbpm documents shows diffirent two persistence unit and two schemas (like jbpm5 and task).



            • 3. Re: JPBM persistence and transaction Questions
              Mauricio Salatino Master

              Yes you can, just use a single persistence.xml with a single persistence unit.. make sure that you use that name to create the session and the local task service instance.

              And everything will be stored in the same schema. Cheers

              1 of 1 people found this helpful
              • 4. Re: JPBM persistence and transaction Questions
                Prabakar Singaram Newbie

                Just want to know more about why do you insist local task service when we use single persistence unit?

                • 5. Re: JPBM persistence and transaction Questions
                  Mauricio Salatino Master

                  Just in the same way, you only need to create a single persisntece unit and use that for both.. session and local human task service.

                  Here is an example: https://github.com/Salaboy/jBPM5-Developer-Guide/blob/master/chapter_08/jBPM5-PersistentProcess/src/test/java/com/salaboy/jbpm5/PersistentProcessTest.java#L375


                  Try it and let us know if you have some troubles.



                  • 6. Re: JPBM persistence and transaction Questions
                    Prabakar Singaram Newbie

                    Yes, It is working fine while using single persistence unit with LocalHT, what happen if I want to use mina or hornetq. Is still applicable using single persistence unit? I tried HT server starts good, but process fails...while creating the knowledgesession from jpaknowlege service, the environment breaks bcos of btm transactionservice

                    (i am using com.mysql.jdbc.jdbc2.optional.MysqlXADataSource not btm)


                    I got the following error...


                    javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.runtime.ht] Unable to build EntityManagerFactory
                    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
                    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
                    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
                    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
                    at com.salaboy.jbpm5.ProcessTest.createKnowledgeSession(ProcessTest.java:102)
                    at com.salaboy.jbpm5.ProcessTest.main(ProcessTest.java:59)
                    Caused by: org.hibernate.HibernateException: Could not obtain BTM transaction manager instance
                    at org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(BTMTransactionManagerLookup.java:50)
                    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:367)
                    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
                    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
                    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
                    ... 5 more
                    Caused by: java.lang.reflect.InvocationTargetException
                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    at java.lang.reflect.Method.invoke(Method.java:600)
                    at org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(BTMTransactionManagerLookup.java:47)
                    ... 9 more
                    Caused by: bitronix.tm.utils.InitializationException: cannot open disk journal
                    at bitronix.tm.BitronixTransactionManager.<init>(BitronixTransactionManager.java:75)
                    at bitronix.tm.TransactionManagerServices.getTransactionManager(TransactionManagerServices.java:62)
                    ... 14 more
                    Caused by: java.io.IOException: The process cannot access the file because another process has locked a portion of the file.
                    at java.io.FileDescriptor.read(Native Method)
                    at java.io.FileDescriptor.read(FileDescriptor.java:77)
                    at java.io.RandomAccessFile.read(RandomAccessFile.java:308)
                    at java.io.RandomAccessFile.readInt(RandomAccessFile.java:762)
                    at bitronix.tm.journal.TransactionLogHeader.<init>(TransactionLogHeader.java:96)
                    at bitronix.tm.journal.TransactionLogAppender.<init>(TransactionLogAppender.java:69)
                    at bitronix.tm.journal.DiskJournal.open(DiskJournal.java:151)
                    at bitronix.tm.BitronixTransactionManager.<init>(BitronixTransactionManager.java:62)
                    ... 15 more