3 Replies Latest reply on Sep 5, 2013 9:43 AM by rhauch

    Container managed transactions on WebSphere 8.0

    andrey.samuleev

      I'm trying to get ModeShape's sessions work in WebSphere 8.0 container managed transactions. (ModeShape 3.5)

       

      Testing transactional behaviour on WebSphere 8.0 embedded EJB container shows that partial data persists on rollback.

      Getting TransactManager from ModeShapes's session (by use of reflection) shows that it is of DummyTransactionManager instance.

      So it seams like Infinispan's GenericTransactionManagerLookup is unable to lookup the WebSphere 8.0 transaction manager.

      As I look though the GenericTransactionManagerLookup source, it is able to find WebSphere TransactionManager factory class only for version 5.1, 5.0 and 4.

       

      Is the Insfinispan TransactionManagerLookup config is the only way to get ModeShape use Application Server transaction manager?

      Maybe, using Resource Adapter can solve this?

        • 1. Re: Container managed transactions on WebSphere 8.0
          hchiorean

          Yes, ModeShape will use whatever transaction manager it gets out of ISPN. That being said, if the existing GenericTransactionManagerLookup doesn't retrieve the tx manager from WebSphere 8, you can always implement your own TransactionManagerLookup and "plug" that into ISPN (it's a 1 method interface).

          1 of 1 people found this helpful
          • 2. Re: Container managed transactions on WebSphere 8.0
            andrey.samuleev

            Thank you for the quick response!

             

            I've implemented custom TransactionManagerLookup, and now container managed transactions work fine in Embedded WebSphere 8 container.

             

            Here is the code:

             

            public class EmbeddableWebSphereTransactionManagerLookup implements TransactionManagerLookup {

                private final String WS8_TM_Factory = "com.ibm.tx.jta.impl.EmbeddableTranManagerSet";

                private TransactionManager tm = null;

             

                private void useDummyTM() {

                    tm = DummyTransactionManager.getInstance();

                }

             

                @Override

                public synchronized TransactionManager getTransactionManager() throws Exception {

                    if (tm != null) {

                        return tm;

                    }

             

                    lookup();

                    return tm;

                }

             

             

                private void lookup() {

                    ClassLoader cl = this.getClass().getClassLoader();

                    Class<?> clazz;

                    try {

                        clazz = Util.loadClassStrict(WS8_TM_Factory, cl);

                    }

                    catch (ClassNotFoundException ex) {

                        System.out.println("TransactionManagerLookup : Error loading class");

                        useDummyTM();

                        return;

                    }

             

                    try {

                        Class<?>[] signature = null;

                        Object[] args = null;

                        Method method = clazz.getMethod("instance", signature);

                        tm = (TransactionManager) method.invoke(null, args);

                    }

                    catch (Exception ex) {

                        System.out.println("TransactionManagerLookup : Error invoking method");

                        useDummyTM();

                        return;

                    }

                }

            }

            • 3. Re: Container managed transactions on WebSphere 8.0
              rhauch

              Thank you for sharing your solution!