3 Replies Latest reply on Feb 14, 2007 5:57 PM by Brian Stansberry

    accessing TreeCacheMBean from remote client

    Padmaja Pradhan Newbie

      Hi,

      I have been using the TreeCache for a while. It gets deployed ok and I can access it fine from my classes within the ear as well as from the JMX console. However, I am having trouble getting to the TreeCacheBean from a java client outside the ear.

      I have looked at the documentation for cache (chapter 12) and
      http://wiki.jboss.org/wiki/Wiki.jsp?page=HowDoIGetRemoteAccessToMyMBean

      Does anybody have a simple example for how to use the RMIAdaptor for TreeCacheMBean?

      Thanks

        • 1. Re: accessing TreeCacheMBean from remote client
          Brian Stansberry Master

          See http://labs.jboss.com/file-access/default/members/jbosscache/freezone/docs/1.4.0/TreeCache/en/html/jboss_integration.html

          The bit in section 13.1 shows how to bind a proxy to your cache into JNDI; external clients can look it up and access it that way.

          If the client is outside the ear but in the AS, you can use the JMX proxy technique shown just a bit above section 13.1.

          • 2. Re: accessing TreeCacheMBean from remote client
            Padmaja Pradhan Newbie

            Hi,

            1. the jboss-service.xml has this:

            <attribute name="TargetName">
             jboss.cache:service=TreeCache
             </attribute>
             <attribute name="JndiName">
             MyCache
             </attribute>
             <attribute name="InvokeTargetMethod">
             true
             </attribute>
             <attribute name="ExportedInterface">
             org.jboss.cache.TreeCacheMBean
             </attribute>


            fyi: I am using old version of cache (1.2.3) but that should not matter here I think.

            2. My client code is:
            Properties env = new Properties();
             env.put(Context.INITIAL_CONTEXT_FACTORY,
             "org.jnp.interfaces.NamingContextFactory");
             env.put("java.naming.factory.url.pkgs",
             "org.jboss.naming:org.jnp.interfaces");
             env.pu(Context.PROVIDER_URL, "jnp://localhost:1099");
             Context ctx = new InitialContext (env);
             //following http://wiki.jboss.org/wiki/Wiki.jsppage=JMXMBeanRemoteProxy
            
            line#51=> cache = (TreeCacheMBean)ctx.lookup("MyCache");
            3. I still get following exception:
            Exception in thread "main" java.lang.NoClassDefFoundError: org/jgroups/ChannelClosedException
             at java.lang.Class.getDeclaredMethods0(Native Method)
             at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
             at java.lang.Class.privateGetPublicMethods(Unknown Source)
             at java.lang.Class.getMethods(Unknown Source)
             at sun.misc.ProxyGenerator.generateClassFile(Unknown Source)
             at sun.misc.ProxyGenerator.generateProxyClass(Unknown Source)
             at java.lang.reflect.Proxy.getProxyClass(Unknown Source)
             at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
             at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
             at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
             at java.rmi.server.RMIClassLoader$2.loadProxyClass(Unknown Source)
             at java.rmi.server.RMIClassLoader.loadProxyClass(Unknown Source)
             at sun.rmi.server.MarshalInputStream.resolveProxyClass(Unknown Source)
             at java.io.ObjectInputStream.readProxyDesc(Unknown Source)
             at java.io.ObjectInputStream.readClassDesc(Unknown Source)
             at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
             at java.io.ObjectInputStream.readObject0(Unknown Source)
             at java.io.ObjectInputStream.readObject(Unknown Source)
             at java.rmi.MarshalledObject.get(Unknown Source)
             at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:57)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:637)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
             at javax.naming.InitialContext.lookup(Unknown Source)
             at gov.lbl.pss2.cache.test.Test.main(Test.java:51)


            Any pointers, insights?

            Thanks


            • 3. Re: accessing TreeCacheMBean from remote client
              Brian Stansberry Master

              You need to have jgroups.jar on the client classpath. TreeCacheMBean includes this method:

              void fetchState(long timeout) throws org.jgroups.ChannelClosedException, org.jgroups.ChannelNotConnectedException;
              


              which is quite poor, but is still around in JBC 1.x to preserve API compatibility.[/url]