10 Replies Latest reply on Jul 15, 2008 5:39 AM by manik

    Problem with transaction (jbossts) configuration in Tomcat

    jreeman

      Hello all,

      I have a problem of configuration with jboss cache :

      My code is just that :


      String value = String.valueOf(random.nextInt());
      Fqn<String> testFqn = Fqn.fromString("/my/tests");
      Node<String, String> rootNode = cache.getRoot();
      
      Node<String, String> testNode = rootNode.addChild(testFqn);
      


      And I have the following error :



      org.jboss.cache.CacheException: java.lang.NoClassDefFoundError: Could not initialize class com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple
      at org.jboss.cache.invocation.AbstractInvocationDelegate.invoke(AbstractInvocationDelegate.java:135)
      at org.jboss.cache.invocation.AbstractInvocationDelegate.invoke(AbstractInvocationDelegate.java:64)
      at org.jboss.cache.invocation.CacheInvocationDelegate.getNode(CacheInvocationDelegate.java:434)
      at org.jboss.cache.invocation.NodeInvocationDelegate.getChild(NodeInvocationDelegate.java:331)
      at org.jboss.cache.invocation.NodeInvocationDelegate.addChild(NodeInvocationDelegate.java:293)
      ...
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple
      at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple.getTransaction(TransactionManagerImple.java:53)
      at org.jboss.cache.interceptors.InvocationContextInterceptor.getTransaction(InvocationContextInterceptor.java:135)
      at org.jboss.cache.interceptors.InvocationContextInterceptor.invoke(InvocationContextInterceptor.java:46)
      at org.jboss.cache.invocation.AbstractInvocationDelegate.invoke(AbstractInvocationDelegate.java:123)
      ... 20 more

      java.lang.NoClassDefFoundError: Could not initialize class com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: org.jboss.cache.CacheException: java.lang.NoClassDefFoundError: Could not initialize class com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple
      at org.jboss.cache.invocation.AbstractInvocationDelegate.invoke(AbstractInvocationDelegate.java:135)
      at org.jboss.cache.invocation.AbstractInvocationDelegate.invoke(AbstractInvocationDelegate.java:64)
      at org.jboss.cache.invocation.CacheInvocationDelegate.getNode(CacheInvocationDelegate.java:434)
      at org.jboss.cache.invocation.NodeInvocationDelegate.getChild(NodeInvocationDelegate.java:331)
      at org.jboss.cache.invocation.NodeInvocationDelegate.addChild(NodeInvocationDelegate.java:293)
      at

      ... 13 more
      Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple
      at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple.getTransaction(TransactionManagerImple.java:53)
      at org.jboss.cache.interceptors.InvocationContextInterceptor.getTransaction(InvocationContextInterceptor.java:135)
      at org.jboss.cache.interceptors.InvocationContextInterceptor.invoke(InvocationContextInterceptor.java:46)
      at org.jboss.cache.invocation.AbstractInvocationDelegate.invoke(AbstractInvocationDelegate.java:123)
      ... 20 more


      The class com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple is in the tomcat class path.
      In fact, I have put all the jboss libraries in the web-inf/lib directory of my web app:

      jta-1.0.1B.jar
      jgroups-2.6.2.jar
      jbossts-common-4.3.0.GA.jar
      jbossjta-4.3.0.GA.jar
      jboss-javaee-5.0.0.Beta3.jar
      jboss-common-logging-spi-2.0.4.GA.jar
      jboss-common-core-2.2.3.GA.jar
      jbosscache-core-2.1.1.GA.jar


      My jboss cache config is :
      <?xml version="1.0" encoding="UTF-8"?>
      
      
      <server>
      
       <!-- Note the value of the 'code' attribute has changed since JBC 1.x -->
       <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=TreeCache">
      
       <!-- Ensure JNDI and the TransactionManager are started before the
       cache. Only works inside JBoss AS; ignored otherwise -->
       <depends>jboss:service=Naming</depends>
       <depends>jboss:service=TransactionManager</depends>
      
       <!-- Configure the TransactionManager -->
       <attribute name="TransactionManagerLookupClass">mypackage.TxManagerLookup</attribute>
      
       <!-- Node locking level : SERIALIZABLE
       REPEATABLE_READ (default)
       READ_COMMITTED
       READ_UNCOMMITTED
       NONE -->
       <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
      
       <!-- Lock parent before doing node additions/removes -->
       <attribute name="LockParentForChildInsertRemove">true</attribute>
      
       <!-- Valid modes are LOCAL (default)
       REPL_ASYNC
       REPL_SYNC
       INVALIDATION_ASYNC
       INVALIDATION_SYNC -->
       <attribute name="CacheMode">INVALIDATION_SYNC</attribute>
      
       <!-- Name of cluster. Needs to be the same for all JBoss Cache nodes in a
       cluster in order to find each other.
       -->
      
       <attribute name="ClusterName">Controllers-Cluster</attribute>
       <!--Uncomment next three statements to use the JGroups multiplexer.
       This configuration is dependent on the JGroups multiplexer being
       registered in an MBean server such as JBossAS. This type of
       dependency injection only works in the AS; outside it's up to
       your code to inject a ChannelFactory if you want to use one.
       -->
      
       <!--
       <depends optional-attribute-name="MultiplexerService"
       proxy-type="attribute">jgroups.mux:name=Multiplexer</depends>
      
       <attribute name="MultiplexerStack">tcp</attribute>
       -->
      
       <!-- JGroups protocol stack properties.
       ClusterConfig isn't used if the multiplexer is enabled above.
       -->
       <attribute name="ClusterConfig">
       <config>
       <!-- UDP: if you have a multihomed machine, set the bind_addr
       attribute to the appropriate NIC IP address -->
       <!-- UDP: On Windows machines, because of the media sense feature
       being broken with multicast (even after disabling media sense)
       set the loopback attribute to true -->
      
       <UDP mcast_addr="228.1.2.3" mcast_port="48866"
       ip_ttl="64" ip_mcast="true" mcast_send_buf_size="150000"
       mcast_recv_buf_size="80000" ucast_send_buf_size="150000"
       ucast_recv_buf_size="80000" loopback="false" />
      
       <PING timeout="2000" num_initial_members="2" />
      
       <MERGE2 min_interval="10000" max_interval="20000" />
      
       <FD shun="true" />
      
       <FD_SOCK />
      
       <VERIFY_SUSPECT timeout="1500" />
      
       <pbcast.NAKACK gc_lag="50"
       retransmit_timeout="600,1200,2400,4800" />
      
       <UNICAST timeout="600,1200,2400,4800" />
      
       <pbcast.STABLE desired_avg_gossip="400000" />
      
       <FC max_credits="2000000" min_threshold="0.10" />
      
       <FRAG2 frag_size="8192" />
      
       <pbcast.GMS join_timeout="5000" shun="true"
       print_local_addr="true" />
      
       <pbcast.STATE_TRANSFER />
       </config>
       </attribute>
      
       <!--
       The max amount of time (in milliseconds) we wait until the
       initial state (ie. the contents of the cache) are retrieved from
       existing members in a clustered environment
       -->
      
       <attribute name="StateRetrievalTimeout">20000</attribute>
       <!--
       Number of milliseconds to wait until all responses for a
       synchronous call have been received.
       -->
      
       <attribute name="SyncReplTimeout">20000</attribute>
      
       <!-- Max number of milliseconds to wait for a lock acquisition -->
       <attribute name="LockAcquisitionTimeout">15000</attribute>
      
       <!-- Shutdown hook behavior. Valid choices are: DEFAULT, REGISTER and DONT_REGISTER.
       If this element is omitted, DEFAULT is used. -->
       <attribute name="ShutdownHookBehavior">DEFAULT</attribute>
      
       <!-- Enables or disables lazy unmarshalling. If omitted, the default is that lazy unmarshalling is enabled. -->
       <attribute name="UseLazyDeserialization">true</attribute>
      
       <!-- Specific eviction policy configurations. This is LRU -->
       <attribute name="EvictionPolicyConfig">
       <config>
       <attribute name="wakeUpIntervalSeconds">5</attribute>
       <!-- This defaults to 200000 if not specified -->
       <attribute name="eventQueueSize">200000</attribute>
       <attribute name="policyClass">org.jboss.cache.eviction.ExpirationPolicy</attribute>
      
       <!-- Cache wide default -->
       <region name="/_default_">
       <attribute name="maxNodes">5000</attribute>
       <attribute name="timeToLiveSeconds">1000</attribute>
       </region>
      
       <region name="/org/jboss/data">
       <attribute name="maxNodes">5000</attribute>
       <attribute name="timeToLiveSeconds">1000</attribute>
       </region>
      
       <region name="/org/jboss/test/data">
       <attribute name="maxNodes">5</attribute>
       <attribute name="timeToLiveSeconds">4</attribute>
       </region>
      
       <region name="/test">
       <attribute name="maxNodes">10000</attribute>
       <attribute name="timeToLiveSeconds">4</attribute>
       </region>
      
       <region name="/maxAgeTest">
       <attribute name="maxNodes">10000</attribute>
       <attribute name="timeToLiveSeconds">8</attribute>
       <attribute name="maxAgeSeconds">10</attribute>
       </region>
       </config>
       </attribute>
       </mbean>
      </server>


      my lookup class * just returns a transaction manager like this :

      public class TxManagerLookup implements org.jboss.cache.transaction.TransactionManagerLookup {
       /**
       * {@inheritDoc}
       */
       @Override
       public TransactionManager getTransactionManager() throws ConfigurationException {
       return com.arjuna.ats.jta.TransactionManager.transactionManager();
       }
      }


      Could you explain to me how I can fix my problems and what I did wrong with this configuration/code ?

      Thx


      ------
      * Before I tried to use the class org.jboss.cache.GenericTransactionManagerLookup but I had this error :


      ERROR [org.jboss.cache.transaction.DummyTransactionManager] - binding of DummyTransactionManager failed
      javax.naming.NamingException: Le Contexte est en lecture seule


        • 1. Re: Problem with transaction (jbossts) configuration in Tomc
          jreeman

          Maybe I have a problem with maven repository I used these dependencies :

          <dependency>
           <groupId>jboss</groupId>
           <artifactId>jboss-common</artifactId>
           <version>4.2.2.GA</version>
           </dependency>
           <dependency>
           <groupId>jboss.jbossts</groupId>
           <artifactId>jbossts-common</artifactId>
           <version>4.3.0.GA</version>
           </dependency>
           <dependency>
           <groupId>jboss.jbossts</groupId>
           <artifactId>jbossjta</artifactId>
           <version>4.3.0.GA</version>
           </dependency>
           <dependency>
           <groupId>org.jboss.cache</groupId>
           <artifactId>jbosscache-core</artifactId>
           <version>2.1.1.GA</version>
           </dependency>


          Are they correct ?

          • 2. Re: Problem with transaction (jbossts) configuration in Tomc
            jreeman

            And create the cache instance like this :

            CacheFactory<String, String> factory = new DefaultCacheFactory<String, String>();
            
             techDataCache = factory.createCache("cache-configuration.xml", true);
             techDataCache.create();


            • 3. Re: Problem with transaction (jbossts) configuration in Tomc
              manik

              From the 4.3.0.GA docs:


              Note that JBossTS 4.3 provides a JTA 1.1 implementation, whereas JBossAS 4.2 ships the JTA 1.0.1b API files. You may therefore also need to copy the JTA 1.1 API into the application server's server/XXX/lib dir
              - lib/ext/jta-1_1-classes.zip


              You also need the jbossjta-properties.xml file on the classpath, which probably means WEB-INF/classes/ ...
              Not that bundling JBossTS in a webapp is a good idea anyhow if you a) have more than one such webapp or b) actually expect crash recovery to work.


              • 4. Re: Problem with transaction (jbossts) configuration in Tomc
                jhalliday

                BTW, do you expect the database connections used by your app to participate in the managed transaction?

                • 5. Re: Problem with transaction (jbossts) configuration in Tomc
                  jreeman

                  Thank you, I will try tomorrow to put all all this together.

                  From the 4.3.0.GA docs:


                  could you give me an url for this doc, and where it is explain how configure jbossjta-properties.xml and so on ?


                  Note that JBossTS 4.3 provides a JTA 1.1 implementation, whereas JBossAS 4.2 ships the JTA 1.0.1b API files.

                  yes, thank you, very useful information.

                  a) have more than one such webapp or

                  Yes I have several but each in a separate tomcat server. I prefer to put in the webapp, so this way, the webapp represents the entire application.

                  b) actually expect crash recovery to work.

                  I didn't know that was a jboss ta functionnality. and I'll look forward on this.

                  BTW, do you expect the database connections used by your app to participate in the managed transaction?


                  No I have no database, only in-memory data.

                  • 6. Re: Problem with transaction (jbossta/jbossts) configuration
                    jreeman

                    I have a cluster with two servers where the following code is executed (I tried with a final rollback and commit).

                    It's a very simple test, and I have to make more tests to know if the lock for cached data works fine but it's a good point that this snippet works fine as expected.

                     String value = String.valueOf(random.nextInt());
                     Fqn<String> testFqn = Fqn.fromString("/my/tests");
                     TransactionManager txManager = new TxManagerLookup().getTransactionManager();
                     txManager.begin();
                    
                     Node<String, String> rootNode = TechnicalDataCache.get().getRoot();
                    
                     Node<String, String> testNode = rootNode.addChild(testFqn);
                     LOG.info("jboss cache test. Value before update is : " + testNode.get("randomInt"));
                     testNode.put("randomInt", value);
                     LOG.info("jboss cache test. Value after update is : " + testNode.get("randomInt"));
                    
                    

                    txManager.commit();

                    or


                    txManager.commit();



                    I used this configuration file :

                    <?xml version="1.0" encoding="UTF-8"?>
                    
                    <server>
                    
                     <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
                     name="jboss.cache:service=TreeCache">
                    
                     <depends>jboss:service=Naming</depends>
                     <depends>jboss:service=TransactionManager</depends>
                    
                     <!--
                     Configure the TransactionManager
                     -->
                     <attribute name="TransactionManagerLookupClass">mypackage.TxManagerLookup</attribute>
                    
                     <!--
                     Isolation level : SERIALIZABLE
                     REPEATABLE_READ (default)
                     READ_COMMITTED
                     READ_UNCOMMITTED
                     NONE
                     -->
                     <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
                    
                     <!--
                     Valid modes are LOCAL
                     REPL_ASYNC
                     REPL_SYNC
                     INVALIDATION_ASYNC
                     INVALIDATION_SYNC
                     -->
                     <attribute name="CacheMode">REPL_SYNC</attribute>
                    
                     <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
                     cluster in order to find each other.
                     -->
                     <attribute name="ClusterName">JBossCache-Cluster</attribute>
                    
                     <!--Uncomment next three statements to enable JGroups multiplexer.
                    This configuration is dependent on the JGroups multiplexer being
                    registered in an MBean server such as JBossAS. -->
                     <!--
                     <depends>jgroups.mux:name=Multiplexer</depends>
                     <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
                     <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
                     -->
                    
                     <!-- JGroups protocol stack properties.
                     ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
                     -->
                     <attribute name="ClusterConfig">
                     <config>
                     <UDP mcast_addr="228.10.10.10"
                     mcast_port="45588"
                     tos="8"
                     ucast_recv_buf_size="20000000"
                     ucast_send_buf_size="640000"
                     mcast_recv_buf_size="25000000"
                     mcast_send_buf_size="640000"
                     loopback="false"
                     discard_incompatible_packets="true"
                     max_bundle_size="64000"
                     max_bundle_timeout="30"
                     use_incoming_packet_handler="true"
                     ip_ttl="2"
                     enable_bundling="false"
                     enable_diagnostics="true"
                    
                     use_concurrent_stack="true"
                    
                     thread_naming_pattern="pl"
                    
                     thread_pool.enabled="true"
                     thread_pool.min_threads="1"
                     thread_pool.max_threads="25"
                     thread_pool.keep_alive_time="30000"
                     thread_pool.queue_enabled="true"
                     thread_pool.queue_max_size="10"
                     thread_pool.rejection_policy="Run"
                    
                     oob_thread_pool.enabled="true"
                     oob_thread_pool.min_threads="1"
                     oob_thread_pool.max_threads="4"
                     oob_thread_pool.keep_alive_time="10000"
                     oob_thread_pool.queue_enabled="true"
                     oob_thread_pool.queue_max_size="10"
                     oob_thread_pool.rejection_policy="Run"/>
                    
                     <PING timeout="2000" num_initial_members="3"/>
                     <MERGE2 max_interval="30000" min_interval="10000"/>
                     <FD_SOCK/>
                     <FD timeout="10000" max_tries="5" shun="true"/>
                     <VERIFY_SUSPECT timeout="1500"/>
                     <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
                     retransmit_timeout="300,600,1200,2400,4800"
                     discard_delivered_msgs="true"/>
                     <UNICAST timeout="300,600,1200,2400,3600"/>
                     <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
                     max_bytes="400000"/>
                     <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
                     view_bundling="true" view_ack_collection_timeout="5000"/>
                     <FRAG2 frag_size="60000"/>
                     <pbcast.STREAMING_STATE_TRANSFER/>
                     <!-- <pbcast.STATE_TRANSFER/> -->
                     <pbcast.FLUSH timeout="0"/>
                     </config>
                     </attribute>
                    
                    
                     <attribute name="FetchStateOnStartup">false</attribute>
                     <attribute name="InitialStateRetrievalTimeout">5000</attribute>
                     <attribute name="SyncReplTimeout">20000</attribute>
                     <attribute name="SyncRollbackPhase">true</attribute>
                     <attribute name="LockAcquisitionTimeout">15000</attribute>
                     <attribute name="UseMarshalling">false</attribute>
                     <attribute name="CacheLoaderShared">true</attribute>
                     <attribute name="CacheLoaderPreload">/</attribute>
                     <attribute name="CacheLoaderPassivation">false</attribute>
                     <attribute name="CacheLoaderFetchPersistentState">true</attribute>
                     <attribute name="CacheLoaderFetchTransientState">false</attribute>
                     <attribute name="CacheLoaderAsynchronous">false</attribute>
                     </mbean>
                    </server>


                    The final dependencies are those :

                    <dependency>
                     <groupId>javax.transaction</groupId>
                     <artifactId>jta</artifactId>
                     <version>1.1</version>
                     </dependency>
                     <dependency>
                     <groupId>jboss.jbossts</groupId>
                     <artifactId>jbossts-common</artifactId>
                     <version>4.3.0.GA</version>
                     </dependency>
                     <dependency>
                     <groupId>jboss.jbossts</groupId>
                     <artifactId>jbossjta</artifactId>
                     <version>4.3.0.GA</version>
                     </dependency>
                     <dependency>
                     <groupId>org.jboss.cache</groupId>
                     <artifactId>jbosscache-core</artifactId>
                     <version>2.1.1.GA</version>
                     </dependency>
                     <dependency>
                     <groupId>oswego-concurrent</groupId>
                     <artifactId>concurrent</artifactId>
                     <version>1.3.4</version>
                     </dependency>


                    Manik,

                    I didtn't find where you read this :
                    Note that JBossTS 4.3 provides a JTA 1.1 implementation, whereas JBossAS 4.2 ships the JTA 1.0.1b API files.


                    • 7. Re: Problem with transaction (jbossts) configuration in Tomc
                      jreeman

                      Could you let me know where you find this sentence in the jboss ta documentation ?

                      Thx

                      • 8. Re: Problem with transaction (jbossts) configuration in Tomc
                        manik

                        Why do you need a transaction manager then (if you are not using crash recovery or a database)?

                        • 9. Re: Problem with transaction (jbossts) configuration in Tomc
                          jreeman

                          First, thx for your response.

                          I planned to use it only to manage in-memory locks but I realized after that I don't need a transaction manager to do that.

                          As a confirmation, I have read here http://www.jboss.com/index.html?module=bb&op=viewtopic&t=138918 your message :

                          Isolation level applies to in-memory locking as well so it is relevant even if you are not using a TM.


                          do this mean this attribute :

                          <attribute name="IsolationLevel">READ_COMMITTED</attribute>
                          


                          would be taken into consideration by jboss cache for in memory cache even if there is no transaction manager ?



                          • 10. Re: Problem with transaction (jbossts) configuration in Tomc
                            manik

                            Yes, this is correct. :-)