5 Replies Latest reply on Nov 11, 2005 12:11 PM by Brian Stansberry

    TreeCache instantiation

    Jarva Jarva Newbie

      Hello.

      Supposedly my TreeCacheMBean is still registrered by this xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <server>
      
       <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
      
      
       <!-- ==================================================================== -->
       <!-- Defines TreeCache configuration -->
       <!-- ==================================================================== -->
      
       <mbean code="org.jboss.cache.TreeCache"
       name="jboss.cache:service=TreeCache">
      
       <depends>jboss:service=Naming</depends>
       <depends>jboss:service=TransactionManager</depends>
      
       <attribute name="JndiName">qnecta/servicio/treecache/TreeCache</attribute>
      
       <!--
       Configure the TransactionManager
       -->
       <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
      
      .......
      
      </server>
      


      And to use this MBean, I've been using this source code and my program:

      MBeanServer serverMBean = MBeanServerLocator.locate();
      try {
       treeCache = (TreeCacheMBean) MBeanProxyExt.create(TreeCacheMBean.class, nombreServicio, serverMBean);
      } catch (MalformedObjectNameException mne) {
       throw new RuntimeException(mne);
      }
      

      And it goes ok. But my problems is at use of standard classes, like MBeanServerFactory and MBeanServerInvocationHandler, like that:

      MBeanServer server = MBeanServerFactory.createMBeanServer();
       ObjectName objName;
       try {
       objName = new ObjectName("jboss.cache:service=TreeCache");
       Object proxy = MBeanServerInvocationHandler.newProxyInstance(server, objName, TreeCacheMBean.class, false);
       treeCache = (TreeCacheMBean)proxy;
       } catch (Exception e) {
       e.printStackTrace();
       }
      


      But when i try this code, it results on this exception:

      10:35:43,600 INFO [STDOUT] javax.management.InstanceNotFoundException: jboss.cache:service=TreeCache is not registered.
      10:35:43,600 INFO [STDOUT] at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:509)
      10:35:43,600 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:259)
      10:35:43,600 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:245)
      10:35:43,600 INFO [STDOUT] at com.acotelsa.qnecta.server.dao.treecache.mbean.DAOTreeCache.setCache(DAOTreeCache.java:201)
      10:35:43,600 INFO [STDOUT] at com.acotelsa.qnecta.server.dao.treecache.mbean.DAOTreeCache.<init>(DAOTreeCache.java:52)
      10:35:43,600 INFO [STDOUT] at com.acotelsa.qnecta.server.dao.treecache.ejb.DAOTreeCache.ejbCreate(DAOTreeCache.java:64)
      10:35:43,615 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      10:35:43,615 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      10:35:43,615 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      10:35:43,615 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
      10:35:43,615 INFO [STDOUT] at org.jboss.ejb.StatelessSessionEnterpriseContext.<init>(StatelessSessionEnterpriseContext.java:63)
      10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.StatelessSessionInstancePool.create(StatelessSessionInstancePool.java:35)
      10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:146)
      10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:80)
      10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
      10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313)
      10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146)
      10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:123)
      10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      10:35:43,615 INFO [STDOUT] at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
      10:35:43,615 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java:870)
      10:35:43,615 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      10:35:43,615 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      10:35:43,615 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      10:35:43,615 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
      10:35:43,615 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
      10:35:43,615 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      10:35:43,615 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      10:35:43,615 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      10:35:43,615 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      10:35:43,615 INFO [STDOUT] at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
      10:35:43,615 INFO [STDOUT] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
      10:35:43,615 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      10:35:43,615 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      10:35:43,615 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      10:35:43,615 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
      10:35:43,615 INFO [STDOUT] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      10:35:43,615 INFO [STDOUT] at sun.rmi.transport.Transport$1.run(Transport.java:148)
      10:35:43,615 INFO [STDOUT] at java.security.AccessController.doPrivileged(Native Method)
      10:35:43,615 INFO [STDOUT] at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      10:35:43,615 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      10:35:43,615 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      10:35:43,615 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)
      


      I've seen the use of this source code on more than one example, what is the problem???
      If I register a MBean by the ".xml", I can't use the second source code way???

      Thanks.

        • 1. Re: TreeCache instantiation
          Jarva Jarva Newbie

          I can't believe it isn't any answer to my question...nobody have the same problem???

          • 2. Re: TreeCache instantiation
            Shahul Hameed Newbie

            Hi,
            I too getting the same problem and dono what to do. Did you got any fixes?

            Error Stack Trace:
            javax.ejb.CreateException: org.jboss.util.NestedRuntimeException: Error creating MBeanProxy: jboss.cache:service=testTreeCache; - nested throwable: (javax.management.InstanceNotFoundException: jboss.cache:service=testTreeCache is not registered.)

            junit.framework.AssertionFailedError: javax.ejb.CreateException: org.jboss.util.NestedRuntimeException: Error creating MBeanProxy: jboss.cache:service=testTreeCache; - nested throwable: (javax.management.InstanceNotFoundException: jboss.cache:service=testTreeCache is not registered.)
            at org.jboss.test.cache.bean.MBeanUnitTestCase.testRollbackTx(MBeanUnitTestCase.java:132)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
            at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
            at junit.extensions.TestSetup.run(TestSetup.java:23)
            at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
            at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
            at junit.extensions.TestSetup.run(TestSetup.java:23)

            My tree-service.xml




            <server>
            
             <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
            
            
             <!-- ==================================================================== -->
             <!-- Defines TreeCache configuration -->
             <!-- ==================================================================== -->
            
             <mbean code="org.jboss.cache.TreeCache"
             name="jboss.cache:service=testTreeCache">
            
             <depends>jboss:service=Naming</depends>
             <depends>jboss:service=TransactionManager</depends>
            
             <!--
             Configure the TransactionManager
             -->
             <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
            
            
             <!--
             Node locking level : SERIALIZABLE
             REPEATABLE_READ (default)
             READ_COMMITTED
             READ_UNCOMMITTED
             NONE
             -->
             <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
            
             <!--
             Valid modes are LOCAL
             REPL_ASYNC
             REPL_SYNC
             -->
             <attribute name="CacheMode">LOCAL</attribute>
            
            ...
            ...
            </server>


            • 3. Re: TreeCache instantiation
              Brian Stansberry Master

              Jarva55,

              You're creating a new MBeanServer and trying to find the tree cache there, which certainly isn't going to work.

              Try

              MBeanServer server = MBeanServerFactory.findMBeanServer("jboss");


              Also, if you're using the MBeanServerLocator approach, it's better to call locateJBoss() instead of just locate(). With JDK 5 if you start another MBeanServer, for example with the -Dcom.sun.management.jmxremote switch, MBeanServerLocator.locate() will return that server, not the one JBoss is using.

              • 4. Re: TreeCache instantiation
                Shahul Hameed Newbie

                Hi Brian,
                But am using the Test cases bundled with jboss 4.0.2 and moreover am using jdk 1.4.2.
                Can u please clarify for these environment.

                Thanks and Regards,
                Shahul.

                • 5. Re: TreeCache instantiation
                  Brian Stansberry Master

                  What test cases? Please explain exactly what you're doing; you're post gives very little information.