10 Replies Latest reply on Feb 10, 2010 2:16 PM by Ronald van Kuijk

    jBPM 4.3 - Which JTA config to use for non-JBoss platform.

    M Porter Newbie

      Hi,

       

      Whilst investigating an issue (and during an upgrade process) to 4.3 running on WLS I have attempted to include the jbpm JTA configuration in our jbpm.cfg.xml as follows (as per a recent update to the docs):-

       

      <import resource="jbpm.tx.jta.cfg.xml"/>

       

      This immediately failed during the engine initialization as the TransactionManager and the UserTransaction are not found in JNDI. Upon inspection of the code it is immediately apparent given the first two lines of code in:-

       

      org.jbpm.pvm.internal.tx.JtaTransaction

       

      The offending lines of code:-

       

      public static final String JNDINAME_USERTRANSACTION_JBOSS_GLOBAL = "UserTransaction";
      public static final String JNDINAME_TRANSACTIONMANAGER_JBOSS_GLOBAL = "java:/TransactionManager";

       

      Hence this will of course not work on another other server than JBoss. These settings should come from my jbpm.hibernate.cfg.xml where the following properties should be used:-

       

          <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
          <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>

          <property name="jta.UserTransaction">java:comp/UserTransaction</property>
          <property name="jndi.class">weblogic.jndi.WLInitialContextFactory</property>

       

      So is it my confusion. Should this <import resource="jbpm.tx.jta.cfg.xml"/> be used only in JBoss platform and on other platforms the default hibernate configuration used <import resource="jbpm.tx.hibernate.cfg.xml"/>. .Or is it a bug in the code ?.

       

      In addition I am more concerned by the following line of code in the actual method that gets the context from JNDI:-

       

      public static Object lookupFromJndi(String jndiName) {
          try {
            InitialContext initialContext = new InitialContext();
            return initialContext.lookup(jndiName);
          } catch (Exception e) {
            throw new JbpmException("couldn't lookup '"+jndiName+"' from jndi: "+e.getMessage()+": "+e.getMessage(), e);
          }
        }

       

      This will of course result in memory leaks and eventual file descriptor issues as the InitialContext is not closed.

       

      Regards

      Martin