4 Replies Latest reply on Dec 1, 2011 5:42 AM by Maciej Swiderski

    Persistence unit name for jBPM5

    mark boletti Newbie

      Hi all !

      I'd like to create my first web application which uses jbpm5 engine. I've added in the META-INF folder the persistence.xml containing the JPA configuration, however if I name the persistence unit org.jbpm.persistence.jpa the deployment fails because the JBPM console is already using that unit name:

       

      DEPLOYMENTS IN ERROR:

        Deployment "vfsfile:/D:/jbpm-installer/jboss-5.1.0.GA/server/default/deploy/jbpm5.war/" is in error due to the following reason(s): java.lang.IllegalStateException: persistence.unit:unitName=#org.jbpm.persistence.jpa is already installed.

       

      Is it possible to use another persistence unit name to jBPM5 application ? (If so, how does the jBPM engine know which is the persistence unit name used? I couldn't find this information in the docs)

      Thanks a lot

      Mark

        • 1. Re: Persistence unit name for jBPM5
          Maciej Swiderski Master

          Sure, you can use another persistence unit. When you create session you need to build up environment that contains entity manager factory, and that is the place where you should use your new name.

          Alternative, could be to get rid of second instance of persistence unit and reuse that one loaded by console.

           

          HTH

          • 2. Re: Persistence unit name for jBPM5
            mark boletti Newbie

            Hello Maciej,

            thanks for your reply. You mean I should add the persistence unit name as property ? I can see the KnowledgeBase can be started with a Property file:

             

            Properties properties = new Properties();

            properties.setProperty( "org.drools.sequential", "true");

            KnowledgeBaseConfiguration kbConf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(properties, myClassLoader);

            KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbConf);

             

            If so which is the right key to set for the persistence unit name ?

            Thanks a lot

            Mark

            • 3. Re: Persistence unit name for jBPM5
              mark boletti Newbie

              Maybe I found it:

               

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

               

              is that one the right place to declare the persistence unit ?

              regards

              Mark

              • 4. Re: Persistence unit name for jBPM5
                Maciej Swiderski Master

                Yes, this is the way you build up entity manager factory but you found for task server and what you are looking for (as original post refers to) is session state persistence.

                So you should look for a place in your application where you create stateful sessions rather than knowledge base. There you should utilize JPAKnowledgeService to create session where one of the arguments for the newStatefulKnowledgeSession method is environment that should contain entity manager factory instance.

                 

                HTH