4 Replies Latest reply on Dec 7, 2011 9:09 AM by renzos

    Configuring a Standalone JBossJTAtransactionManager

    renzos

      Hi guys,

       

      I need to configure a standalone transaction manager for infinispan 4.2.1Final, as the Dummy manager I'm using causes problems with my multithread application (often I get an exception on transactionManager.begin() maybe because the Dummy can't handle different threads with the same id).

      I'm developing infinispan with NetBeans 7.0.1 and the "jbossjta-4.15.0.Final.jar" has been correctly imported in the project properties, but I can't find a step-by-step guide to configure and use the standalone JTA with infinispan, such as declarations to do, imports and so on.

      Thanks a lot for your support.

        • 1. Re: Configuring a Standalone JBossJTAtransactionManager
          galder.zamarreno

          With the jar in place, you just need to add the transaction manager lookup class to your config, i.e.

           

          <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup"...

           

          More info: https://docs.jboss.org/author/display/ISPN/Infinispan+transactions

          • 2. Re: Configuring a Standalone JBossJTAtransactionManager
            renzos

            Hi, unfortunately it doesn't work. I included jbossjta-4.15.0.Final.jar in my classpath and changed the lookup class in the infinispan config file but nothing.

             

            Here my test code, very simple:

             

            import java.io.IOException;

            import javax.transaction.HeuristicMixedException;

            import javax.transaction.HeuristicRollbackException;

            import javax.transaction.NotSupportedException;

            import javax.transaction.RollbackException;

            import javax.transaction.SystemException;

            import javax.transaction.TransactionManager;

            import org.apache.log4j.Logger;

            import org.apache.log4j.xml.DOMConfigurator;

            import org.infinispan.Cache;

            import org.infinispan.manager.DefaultCacheManager;

            import org.infinispan.manager.EmbeddedCacheManager;

             

            public class Infinitraining {

                private static EmbeddedCacheManager manager;

                private static Logger logger = Logger.getLogger(Infinitraining.class);

                private static TransactionManager tm;

               

                public static void main(String[] args) throws IOException, NotSupportedException, SystemException, RollbackException, HeuristicMixedException, HeuristicRollbackException, Exception {

                    DOMConfigurator.configure("log4j.xml");

                    logger.info("TestLog");

                    manager = new DefaultCacheManager("my-config-file.xml");

                    Cache<Object, Object> cache = manager.getCache("trainingCache");

                    tm=cache.getAdvancedCache().getTransactionManager();

                   

                    tm.begin();

                    cache.put(1, 35);

                    System.out.println("getting key 1: "+cache.get(1));

                    tm.commit();

                    System.exit(0);

                }

            }

             

             

             

            And the error I get:

             

             

             

            INFO  TransactionManagerFactory - failed looking up TransactionManager, will not use transactions

            java.lang.reflect.InvocationTargetException

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                at java.lang.reflect.Method.invoke(Method.java:597)

                at org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup.getTransactionManager(JBossStandaloneJTAManagerLookup.java:54)

                at org.infinispan.factories.TransactionManagerFactory.construct(TransactionManagerFactory.java:54)

                at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:315)

                at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:251)

                at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:840)

                at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:225)

                at org.infinispan.factories.ComponentRegistry.registerComponent(ComponentRegistry.java:120)

                at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:192)

                at org.infinispan.factories.InternalCacheFactory.bootstrap(InternalCacheFactory.java:102)

                at org.infinispan.factories.InternalCacheFactory.createAndWire(InternalCacheFactory.java:77)

                at org.infinispan.factories.InternalCacheFactory.createCache(InternalCacheFactory.java:61)

                at org.infinispan.manager.DefaultCacheManager.createCache(DefaultCacheManager.java:509)

                at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:439)

                at infinitraining.Infinitraining.main(Infinitraining.java:29)

            Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.arjuna.ats.arjuna.logging.tsLogger

                at com.arjuna.ats.internal.arjuna.common.ClassloadingUtility.loadClass(ClassloadingUtility.java:78)

                at com.arjuna.ats.internal.arjuna.common.ClassloadingUtility.loadAndInstantiateClass(ClassloadingUtility.java:119)

                at com.arjuna.ats.jta.common.JTAEnvironmentBean.getTransactionManager(JTAEnvironmentBean.java:158)

                at com.arjuna.ats.jta.TransactionManager.transactionManager(TransactionManager.java:70)

                ... 18 more

            • 3. Re: Configuring a Standalone JBossJTAtransactionManager
              sannegrinovero

              Hi Renzo,

              looks like you have some dependency incompatibility, possibly having multiple JTA implementations around.

              Infinispan 4.2.x was tested with JBoss TransactionManager 4.9.0.GA, Infinispan 5.x expects 4.15.1.Final.

               

              The class you're not finding on the classpath exists only in 4.15.x, not before. Since it's being looked for, it looks like you have multiple JTA components on the classpath, possibly mixing different jars in different versions.

               

              If you can't find it looking in your classpath, I'd suggest to use TattleTale to inspect your classpath.

              • 4. Re: Configuring a Standalone JBossJTAtransactionManager
                renzos

                Great !! Adding 4.9.0.GA and common-logging-1.1.jar now it works !!

                Thanks