1 Reply Latest reply on Apr 2, 2014 3:39 AM by swiderski.maciej

    How do I wired up JbpmServicesPersistenceManager?

    tmcclure0501

      I have a MVP application running as part of JBPM workbench.  I notice in the human task service code this object can be used through injection however when I try to do this in my application I get a not bound issue on the injection of this interface - somewhere I am missing some plumbing to wire up this reference.  I am able to get my application to work but instating everything as shown in the class below but I am concern as I think I am instantiating the EntityManagerFactory when I do not have to:

       

      The class using  persistence does this:

          private JbpmServicesPersistenceManager pm = DakotaComponent.getPM();

       

      The class that initializing the subsystem:

      public abstract class DakotaComponent {

       

       

        private static EntityManagerFactory emf = null;

        private static JbpmServicesPersistenceManager pm = null;

       

        /**

        * Method to instantiate entity manager - override create tables when not in

        * test mode.

        *

        * @param createTables

        *            if true have JPA create tables

        * @return EntityManagerFactory for creating entity manager

        */

        public static EntityManagerFactory getEntityManagerFactory(

        boolean createTables) {

        if (emf == null) {

        if (createTables) {

        emf = Persistence.createEntityManagerFactory("org.jbpm.domain");

        } else {

        HashMap<String, String> params = new HashMap<String, String>();

        params.put("hibernate.hbm2ddl.auto", "none");

        emf = Persistence.createEntityManagerFactory("org.jbpm.domain",

        params);

       

       

        }

        }

       

        return emf;

        }

       

        public static JbpmServicesPersistenceManager getPM()

        {

       

        if (pm == null)

        {

        JbpmServicesPersistenceManagerImpl pmImpl = new JbpmServicesPersistenceManagerImpl();

       

        EntityManagerFactory emf =  getEntityManagerFactory(false);

        pmImpl.setEmf(emf);

        EntityManager em = emf.createEntityManager();

        pmImpl.setEm(emf.createEntityManager());

        pmImpl.setTransactionManager(new JbpmJTATransactionManager());

        pm =pmImpl;

        }

        return  pm;

        }

      }

        • 1. Re: How do I wired up JbpmServicesPersistenceManager?
          swiderski.maciej

          I would recommend to move to 6.0.1 as there was quite some refactoring which resulted in removal of the class you trying to wire up. This will make your transition to further version of jbpm much easier.

           

          Can you explain why you need to use this class? It is considered internal for jbpm and should not be used by application code actually.

           

          HTH