8 Replies Latest reply on Oct 28, 2002 3:13 PM by Chris Fong

    remote mbean operations

    Emily Newbie

      I am trying to connect to the SystemProperties mBean from a client to retreive some property values. First of all, is this possible? I wrote some code to do so but I always get a RuntimeMBeanException.

      I tried to test remotely connecting by using some code I found in another post that someone had gotten to work.
      This is my client's code...

      Context ctx = new InitialContext();
      String adaptorName = "jmx:local:rmi";
      RMIAdaptor adaptor = (RMIAdaptor) ctx.lookup(adaptorName);
      RemoteMBeanServer server = new RMIConnectorImpl(adaptor);

      String DEPLOYER_NAME = "jboss.system:service=MainDeployer";
      ObjectName objectName = new ObjectName(DEPLOYER_NAME);
      System.err.println("getMBeanCount()="+server.getMBeanCount());

      System.err.println("isRegistered("+objectName.getCanonicalName()+")="+server.isRegistered(objectName));


      And here is the client's output:
      getMBeanCount()=217
      javax.management.RuntimeMBeanException
      at org.jboss.jmx.connector.rmi.RMIConnectorImpl.isRegistered(RMIConnectorImpl.java:316)
      at com.scilearn.client.UploadClient.upload(UploadClient.java:89)
      at com.scilearn.client.UploadClient.main(UploadClient.java:175)

      So it looks like I'm connecting to the server but unable to invoke MBean operations. Any advice?

      Thanks,
      Emily

        • 1. Re: remote mbean operations
          Adrian Brock Master

          Can you catch the RuntimeMBeanException and
          print out the result of getTargetException();

          Regards,
          Adrian

          • 2. Re: remote mbean operations
            Juha Lindfors Master

            > I am trying to connect to the SystemProperties mBean
            > from a client to retreive some property values.
            > First of all, is this possible?

            Yes =)

            > This is my client's code...
            >
            > Context ctx = new InitialContext();
            > String adaptorName = "jmx:local:rmi";
            > RMIAdaptor adaptor = (RMIAdaptor)
            > ctx.lookup(adaptorName);
            > RemoteMBeanServer server = new
            > RMIConnectorImpl(adaptor);
            >
            > String DEPLOYER_NAME =
            > "jboss.system:service=MainDeployer";
            > ObjectName objectName = new
            > ObjectName(DEPLOYER_NAME);
            > System.err.println("getMBeanCount()="+server.getMBeanC
            > unt());
            >
            > System.err.println("isRegistered("+objectName.getCanon
            > calName()+")="+server.isRegistered(objectName));
            >
            >
            > And here is the client's output:
            > getMBeanCount()=217

            You are succesfully connecting to the server, since you are able to get the MBean count (217).

            IsRegistered seems to fail, not sure why. Maybe a bug in the RMI connector (the returned exception is not very helpful either, you should check the exception it wraps).

            Connector rewrite is on the todo list.

            Try if you can retrieve the attributes though, server.getAttribute(objectName, "ServerName");

            That should work.

            >
            > Thanks,
            > Emily

            -- Juha

            • 3. Re: remote mbean operations
              Emily Newbie

              I caught the Runtime Exception and printed out the target exception, with this result:

              org.jboss.util.NestedRuntimeException: RemoteException occurred in server thread; nested exception is:
              java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
              java.io.InvalidClassException: javax.management.ObjectName; local class incompatible: stream classdesc seri
              alVersionUID = 1081892073854801359, local class serialVersionUID = 2846767152916764670; - nested throwable: (java.r
              mi.ServerException: RemoteException occurred in server thread; nested exception is:
              java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
              java.io.InvalidClassException: javax.management.ObjectName; local class incompatible: stream classdesc seri
              alVersionUID = 1081892073854801359, local class serialVersionUID = 2846767152916764670)
              serviceURL is null
              - javax.management.RuntimeMBeanException
              javax.management.RuntimeMBeanException
              at org.jboss.jmx.connector.rmi.RMIConnectorImpl.getMBeanInfo(RMIConnectorImpl.java:527)
              at com.scilearn.client.UploadClient.upload(UploadClient.java:102)
              at com.scilearn.client.UploadClient.main(UploadClient.java:185)

              So it looks like my client's copy of ObjectName is incompatible with the server's copy? How can this be and how do I fix it?

              Thanks again,
              Emily

              OH, I was also unable to get server.getAttribute to work, I also got the same RuntimeException, which makes sense.

              • 4. Re: remote mbean operations
                Adrian Brock Master

                I've only just added the code to make JBoss
                Serialization compatible with the jmx 1.1 spec.
                Sun forgot to specify serialization in the 1.0 spec :-)

                You can get this version from CVS on Branch_3_2 or HEAD.
                Looks like you are using jmxri.jar 1.1 so you don't
                have to change any system properties.

                Alternatively, use jboss-jmx.jar on the client.

                Regards,
                Adrian

                • 5. Re: remote mbean operations
                  Emily Newbie

                  Thank you so much for your prompt help. I now have my client working.

                  I have another quick, rather silly question. Why is the RMI adaptor named "jmx:local:rmi" instead of "jmx:localhost:rmi" as I would expect? From where is the hostname retreived? I noticed there is also another adaptor named "jmx:eshort:rmi" in my JNDIView (eshort is the name of my machine).

                  Thanks,
                  Emily

                  • 6. Re: remote mbean operations
                    Adrian Brock Master

                    I think because sometimes localhost is a valid host name,
                    it would register it twice.

                    Regards,
                    Adrian

                    • 7. Re: remote mbean operations
                      Chris Fong Newbie

                      Hi Adrian,

                      If I am compiling the server and client separately in two different platforms with the same source code and same version of JVM (the server version is 2.4.4). Will I encounter the same problem? I am currently having the serialVersionUID mismatched as well and wondering is it a problem in my side.

                      Thanks,

                      --Chris

                      • 8. Re: remote mbean operations
                        Chris Fong Newbie

                        I bet I must be having some stale classes in my classpath. After rerunning everything, my problem is solved. Please ignore my previous mail...

                        Thanks,

                        --Chris