7 Replies Latest reply on May 24, 2004 9:36 AM by ben.wang

    Problem with TreeCache in JBoss 3.2.3

    victor.sauermann

      Hello!
      I'm trying to create a TreeCache in a JBoss Server Cluster with 3 Servers. They share the same Partition (DefaultPartition) and are a clean server/all configuration.
      Now I tried to establish a Stateless Session Bean with a single method, shown below:

       public
       void createTreeCache()
       {
       //## begin ControllerBean::createTreeCache%40A1C2520244.body preserve=yes
       try
       {
       TreeCache tree = new TreeCache();
       tree.setClusterName("demo-cluster");
       tree.setTransactionManagerLookupClass( "org.jboss.cache.DummyTransactionManagerLookup" );
       tree.setCacheMode(TreeCache.REPL_SYNC);
       tree.startService(); // kick start tree cache
       tree.put("/a/b/c", "name", "Ben");
       java.util.Iterator i = tree.getChildrenNames( "/a/b/c" ).iterator();
       while( i.hasNext() )
       System.out.println(">>>>>>>>>>>" + i.next().toString() + "<<<<<<<<<<<");
       tree.remove("/a/b");
       tree.stopService();
       }
       catch(Exception e)
       {
       e.printStackTrace();
       }
       //## end ControllerBean::createTreeCache%40A1C2520244.body
       } // --- end of createTreeCache --------------------------------------------
      

      I know I should use an property XML file, but for now...

      Now, here is my problem:
      First I started only one server and the JBoss output was:

      10:10:56,332 INFO [MainDeployer] Deployed package: file:/D:/Projects/Java/jboss3/server/all/deploy/test-ejb.jar
      10:10:59,276 INFO [STDOUT] >>>>>>>>>>>Creating<<<<<<<<<<<
      10:10:59,276 INFO [TreeCache] cache mode is REPL_SYNC
      10:10:59,317 INFO [STDOUT]
      -------------------------------------------------------
      GMS: address is pc153:4699
      -------------------------------------------------------
      10:11:01,940 INFO [TreeCache] viewAccepted(): new members: [pc153:4699]
      10:11:01,970 INFO [TreeCache] state could not be retrieved (must be first member in group)
      10:11:01,970 ERROR [STDERR] java.lang.NullPointerException
      10:11:01,980 ERROR [STDERR] at com.siemens.is.its.airfield.aglseries.test.ControllerBean.createTreeCache(ControllerBean.java:182)
      10:11:02,000 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      10:11:02,010 INFO [TreeCache] setState(): new cache is null (maybe first member in cluster)
      ... (many more of 'em!)

      Now, where lies the problem, is this way I've chosen the correct way of getting values out of the TreeCache?

      Greetings and many thanks
      Victor Sauermann

        • 1. Re: Problem with TreeCache in JBoss 3.2.3

          Hi,

          Can you porvide more explicit stack trace? It's hard to tell where it went wrong.

          Thanks,

          -Ben

          • 2. Re: Problem with TreeCache in JBoss 3.2.3
            victor.sauermann

            Hello!

            Here is some. I hope the amount fits your interest.
            Many thanks so far

            Vic


            14:23:32,504 INFO [MainDeployer] Deployed package: file:/D:/Projects/Java/jboss3/server/all/deploy/test-ejb.jar
            14:24:17,359 INFO [STDOUT] >>>>>>>>>>>Creating<<<<<<<<<<<
            14:24:17,469 ERROR [DummyTransactionManager] binding of DummyTransactionManager failed
            javax.naming.NameAlreadyBoundException
            at org.jnp.server.NamingServer.bind(NamingServer.java:130)
            at org.jnp.interfaces.NamingContext.bind(NamingContext.java:488)
            at org.jnp.interfaces.NamingContext.bind(NamingContext.java:459)
            at javax.naming.InitialContext.bind(InitialContext.java:355)
            at org.jboss.cache.transaction.DummyTransactionManager.getInstance(DummyTransactionManager.java:41)
            at org.jboss.cache.DummyTransactionManagerLookup.getTransactionManager(DummyTransactionManagerLookup.java:17)
            at org.jboss.cache.TreeCache.startService(TreeCache.java:867)
            at com.siemens.is.its.airfield.aglseries.test.ControllerBean.createTreeCache(ControllerBean.java:180)
            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.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
            at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
            at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
            at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
            at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:297)
            at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
            at org.jboss.ejb.plugins.CleanShutdownInterceptor.invoke(CleanShutdownInterceptor.java:264)
            at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
            at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
            at org.jboss.ejb.Container.invoke(Container.java:700)
            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.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
            at org.jboss.invocation.jrmp.server.JRMPInvokerHA.invoke(JRMPInvokerHA.java:163)
            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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
            at sun.rmi.transport.Transport$1.run(Transport.java:148)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
            at java.lang.Thread.run(Thread.java:534)
            14:24:17,829 INFO [TreeCache] cache mode is REPL_SYNC
            14:24:17,879 INFO [STDOUT]
            -------------------------------------------------------
            GMS: address is pc153:4433
            -------------------------------------------------------
            14:24:19,912 INFO [TreeCache] viewAccepted(): new members: [pc153:4433]
            14:24:19,912 INFO [TreeCache] state could not be retrieved (must be first member in group)
            14:24:19,942 ERROR [STDERR] java.lang.NullPointerException
            14:24:19,942 ERROR [STDERR] at com.siemens.is.its.airfield.aglseries.test.ControllerBean.createTreeCache(ControllerBean.java:1
            82)
            14:24:19,962 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            14:24:19,972 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            14:24:19,982 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            14:24:19,992 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
            14:24:20,012 INFO [TreeCache] setState(): new cache is null (maybe first member in cluster)
            14:24:20,022 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.j
            ava:683)
            14:24:20,032 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterce
            ptor.java:185)
            14:24:20,053 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterc
            eptor.java:72)
            14:24:20,083 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
            14:24:20,083 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:297)
            14:24:20,103 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
            14:24:20,113 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
            14:24:20,123 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
            14:24:20,133 ERROR [STDERR] at org.jboss.ejb.plugins.CleanShutdownInterceptor.invoke(CleanShutdownInterceptor.java:264)
            14:24:20,143 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:1
            22)
            14:24:20,163 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
            14:24:20,173 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:700)
            14:24:20,183 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            14:24:20,193 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            14:24:20,203 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            14:24:20,213 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
            14:24:20,223 ERROR [STDERR] at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
            14:24:20,233 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
            14:24:20,243 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvokerHA.invoke(JRMPInvokerHA.java:163)
            14:24:20,253 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            14:24:20,263 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            14:24:20,273 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            14:24:20,283 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
            14:24:20,293 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
            14:24:20,303 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Transport.java:148)
            14:24:20,313 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
            14:24:20,323 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
            14:24:20,333 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
            14:24:20,343 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
            14:24:20,353 ERROR [STDERR] at java.lang.Thread.run(Thread.java:534)


            • 3. Re: Problem with TreeCache in JBoss 3.2.3
              belaban

              You'll need to run with the JBossTransactionManagerLookup class rather than the DummyTxManagerLookup. The latter is only usable outside of JBoss.
              Bela

              • 4. Re: Problem with TreeCache in JBoss 3.2.3
                victor.sauermann

                Thanks!
                Now the app ran fine.
                But now I'm wondering about the "best practises" in establishing TreeCache for a Clustered Environment.
                Mainly: How do I initialize a cluster wide TreeCache? Via MBean?

                • 5. Re: Problem with TreeCache in JBoss 3.2.3
                  belaban

                  From your app (e.g. via MBean or JNDI lookup).
                  Bela

                  • 6. Re: Problem with TreeCache in JBoss 3.2.3
                    victor.sauermann

                    Okay, okay!

                    I think I'm reaching aim now.
                    But some little problems are still available...

                    1.) I created a sar file containing a MBean. This MBean reads out a XML file. Then it instantiates the TreeCache. Afterwards it binds this object with a JNDI name. At last: It adds the XML file content to the TreeCache.

                    A survey of the code:

                    TreeCache cache = new TreeCache();
                    PropertyConfigurator config = new PropertyConfigurator();
                    config.configure(cache, "..\\server\\all\\deploy\\local-service.xml"); // read in generic local xml
                    cache.startService();
                    //Bind object to JNDI namespace
                    InitialContext ctx = new InitialContext();
                    ctx.bind( "java:/TreeCache", cache );
                    


                    Now the JBoss cluster establishes some accepted views to this TreeCache Instance.

                    Now I created a StatelessSession Bean, which shall read out the content.

                    Here is a short code snippet:
                    TreeCache theCache = null;
                    try
                    {
                     InitialContext ctx = new InitialContext();
                    //The following line is line Number 134 in com.siemens.is.its.airfield.aglseries.test.POJOTestBean.getValues()
                     Object o = ctx.lookup( "java:/TreeCache" );
                     theCache = (TreeCache)javax.rmi.PortableRemoteObject.narrow(o, TreeCache.class );
                     System.out.println(">>>>>Entering: POJOTestBean::getValues()<<<<<");
                     String key = "aglcore";
                     Node n = theCache.get( key );
                     System.out.println("\tReturned object: " + n.toString());
                     System.out.println(">>>>>Leaving: POJOTestBean::getValues()<<<<<");
                    
                    }
                    catch(Exception e)
                    {
                     e.printStackTrace();
                    }
                    


                    But the JBoss server only responses with an Exception like this:

                    14:57:28,881 INFO [StatelessSessionContainer] Started jboss.j2ee:jndiName=com.siemens.is.its.airfield.aglseries.test.POJOTest,service=EJB
                    14:57:28,891 INFO [EjbModule] Started jboss.j2ee:module=test-ejb.jar,service=EjbModule
                    14:57:28,901 INFO [EJBDeployer] Deployed: file:/D:/Projects/Java/jboss3/server/all/deploy/test-ejb.jar
                    14:57:28,931 INFO [MainDeployer] Deployed package: file:/D:/Projects/Java/jboss3/server/all/deploy/test-ejb.jar
                    14:57:37,414 ERROR [STDERR] EJBStatelessSessionBean::setSessionContext is not implemented yet.
                    14:57:37,414 ERROR [STDERR] EJBStatelessSessionBean::ejbCreate is not implemented yet.
                    14:57:37,424 ERROR [STDERR] javax.naming.NameNotFoundException: TreeCache not bound
                    14:57:37,444 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
                    14:57:37,454 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
                    14:57:37,464 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
                    14:57:37,474 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
                    14:57:37,484 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
                    14:57:37,494 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
                    14:57:37,504 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:347)
                    14:57:37,514 ERROR [STDERR] at com.siemens.is.its.airfield.aglseries.test.POJOTestBean.getValues(POJOTestBean.java:134)
                    14:57:37,524 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    14:57:37,534 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    14:57:37,544 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    14:57:37,554 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
                    14:57:37,564 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
                    14:57:37,584 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
                    14:57:37,594 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
                    14:57:37,604 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
                    14:57:37,614 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:297)
                    14:57:37,624 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
                    14:57:37,634 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
                    14:57:37,644 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
                    14:57:37,654 ERROR [STDERR] at org.jboss.ejb.plugins.CleanShutdownInterceptor.invoke(CleanShutdownInterceptor.java:264)
                    14:57:37,664 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
                    14:57:37,674 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
                    14:57:37,694 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:700)
                    14:57:37,704 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    14:57:37,714 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    14:57:37,724 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    14:57:37,734 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
                    14:57:37,744 ERROR [STDERR] at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                    14:57:37,754 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                    14:57:37,764 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvokerHA.invoke(JRMPInvokerHA.java:163)
                    14:57:37,774 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    14:57:37,784 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    14:57:37,794 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    14:57:37,814 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
                    14:57:37,824 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
                    14:57:37,834 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Transport.java:148)
                    14:57:37,854 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
                    14:57:37,854 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                    14:57:37,864 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
                    14:57:37,874 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
                    14:57:37,894 ERROR [STDERR] at java.lang.Thread.run(Thread.java:534)

                    What went wrong. Is this way I've chosen the right way?

                    Greetings Vic

                    • 7. Re: Problem with TreeCache in JBoss 3.2.3

                      The testsuite under jboss-head has a test case that demonstrate how to access TreeCache MBean from SLSB. THe files are src/main/org/jboss/test/cache/test/local/MBeanUnitTest.java and src/main/org/jboss/test/cache/test/bean/TreeCacheMBeanTesterBean.java.

                      Please check it out.

                      Thanks,

                      -Ben