11 Replies Latest reply on Mar 2, 2005 3:36 AM by Bela Ban

    JBossCache in Tomcat w/ Transaction Support

    Bill Bejeck Newbie

      Hi,

      I am currently evaluating JBossCache for my company. For our purposes we will need to use JBossCache inside of Tomcact. For transaction support I have added the JOTM jar files and used the configuration example from the JOTM docs. In the JBossCache config file I set the JBossTransactionManagerLookup class to org.jboss.cache.GenericTransactionManagerLookup which seems to work fine. I have two instances of tomcat on the same machine for my environment. When I put objects into the tree with the following code

      try {
       ut.begin();
       tree.put(node,currentCount,item);
       ut.commit();
       } catch(Exception e){
       log.error("Error adding to cache",e);
       try{
       ut.rollback();
       }catch(Exception e2){}
      
       }finally{
       //sets ThreadLocal treeCache varible to null
       TreeCacheUtil.closeTreeCacheSession();
       //sets ThreadLocal transaction varible to null
       UserTransactionUtil.transactionDone();
       tree=null;
       ut=null;
       }

      from node 1 I get the following error on node 2
      org.jboss.util.NestedRuntimeException: ; - nested throwable: (java.lang.Exception: method call _put cannot be converted to a modification)
       at org.jboss.cache.interceptors.CacheStoreInterceptor$SynchronizationHandler.beforeCompletion(CacheStoreInterceptor.java:236)
       at org.objectweb.jotm.SubCoordinator.doBeforeCompletion(SubCoordinator.java:1078)
       at org.objectweb.jotm.SubCoordinator.commit_one_phase(SubCoordinator.java:375)
       at org.objectweb.jotm.TransactionImpl.commit(TransactionImpl.java:219)
       at org.jboss.cache.interceptors.ReplicationInterceptor.replicate(ReplicationInterceptor.java:182)
       at org.jboss.cache.TreeCache._replicate(TreeCache.java:2679)
       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:324)
       at org.jgroups.blocks.MethodCall.invoke(MethodCall.java:236)
       at org.jgroups.blocks.RpcDispatcher.handle(RpcDispatcher.java:220)
       at org.jgroups.blocks.RequestCorrelator.handleRequest(RequestCorrelator.java:615)
       at org.jgroups.blocks.RequestCorrelator.receiveMessage(RequestCorrelator.java:512)
       at org.jgroups.blocks.RequestCorrelator.receive(RequestCorrelator.java:326)
       at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.handleUp(MessageDispatcher.java:722)
       at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.access$300(MessageDispatcher.java:554)
       at org.jgroups.blocks.MessageDispatcher$1.run(MessageDispatcher.java:691)
       at java.lang.Thread.run(Thread.java:534)
      Caused by: java.lang.Exception: method call _put cannot be converted to a modification
       at org.jboss.cache.interceptors.CacheStoreInterceptor.convertMethodCallToModification(CacheStoreInterceptor.java:192)
       at org.jboss.cache.interceptors.CacheStoreInterceptor.prepareCacheLoader(CacheStoreInterceptor.java:144)
       at org.jboss.cache.interceptors.CacheStoreInterceptor.access$000(CacheStoreInterceptor.java:22)
       at org.jboss.cache.interceptors.CacheStoreInterceptor$SynchronizationHandler.beforeCompletion(CacheStoreInterceptor.java:222)
       ... 18 more
      2005-02-22 12:46:37,781 DEBUG http-8080-Processor25 treecache.util.TreeCacheUtil - treecache null, setting to instance
      2005-02-22 12:46:52,796 ERROR http-8080-Processor25 org.jboss.cache.lock.IdentityLock - read lock for /treecache/pojo/Item could not be acquired after 15000 ms. Lock map ownership Read lock owners: []
      Write lock owner: <172.30.3.123:7805>:2
       (caller=Thread[http-8080-Processor25,5,main])
      2005-02-22 12:46:52,796 DEBUG http-8080-Processor25 org.jboss.cache.Node - failure acquiring lock: fqn=/treecache/pojo/Item, requester=Thread[http-8080-Processor25,5,main], lock=write owner=<172.30.3.123:7805>:2
      2005-02-22 12:46:52,796 ERROR http-8080-Processor25 treecache.servlets.ViewNodesServlet - Error retreiving nodes from tree
      org.jboss.cache.lock.TimeoutException: lock for /treecache/pojo/Item could not be acquired after 15000ms. Lock map ownership Read lock owners: []
      Write lock owner: <172.30.3.123:7805>:2
      
       at org.jboss.cache.lock.IdentityLock.acquireReadLock(IdentityLock.java:227)
       at org.jboss.cache.Node.acquireReadLock(Node.java:418)
       at org.jboss.cache.Node.acquire(Node.java:399)
       at org.jboss.cache.interceptors.LockInterceptor.lock(LockInterceptor.java:187)
       at org.jboss.cache.interceptors.LockInterceptor.invoke(LockInterceptor.java:134)
       at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:40)
       at org.jboss.cache.interceptors.CreateIfNotExistsInterceptor.invoke(CreateIfNotExistsInterceptor.java:47)
       at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:40)
       at org.jboss.cache.interceptors.CacheStoreInterceptor.invoke(CacheStoreInterceptor.java:103)
       at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:40)
       at org.jboss.cache.interceptors.CacheLoaderInterceptor.invoke(CacheLoaderInterceptor.java:111)
       at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:40)
       at org.jboss.cache.interceptors.ReplicationInterceptor.invoke(ReplicationInterceptor.java:51)
       at org.jboss.cache.TreeCache.invokeMethod(TreeCache.java:3078)
       at org.jboss.cache.TreeCache.getKeys(TreeCache.java:1559)
       at org.jboss.cache.TreeCache.getKeys(TreeCache.java:1548)
       at treecache.servlets.ViewNodesServlet.doPost(Unknown Source)
       at treecache.servlets.ViewNodesServlet.doGet(Unknown Source)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
       at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
       at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
       at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
       at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)


      Any ideas on why this is happening? If I comment out the TransactionManagerLookupClass section performance is fine.

      Thanks,
      Bill