6 Replies Latest reply on May 19, 2006 6:12 AM by Dimitris Andreadis

    Question about "Connecting to JMX"

    Bastian Schaefer Newbie

      Hello,

      My Name is Bastian.
      I try to connect to the JBoss Application-Server to read out it's MBeans.
      I tried the "2.3.2. Connecting to JMX Using RMI" chapter in the Admin-Guide.

      It works, but I am not satisfied.
      I have several Questions to this:

      1. If I want to use this programm and change it, outside the example-context with the build.xml file I have to build it, take the resources-Directory (with the property, and policy-Files inside) and use it in my classpath to be able to start and use the application in my Eclipse IDE.
      I am not confident with these property and policy-Files. I don't even know why they are there, because I have never seen something comparable on the other App-Servers I tried to connect.
      How can I use the

      InitialContext ic = new InitialContext();
       RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/invoker/RMIAdaptor");
      

      out of the box, without using the property-Files out of the Example.
      I haven't even found a word about these files in the Admin-Guide... It just says: "Start the application like that and it will run..."

      2. So well: With a lot of work I am able to run the Example-Application in my IDE an try to get some MBean Information...
      ObjectName theName = new ObjectName("jboss.jca:name=DefaultDS,service=ManagedConnectionFactory");
      MBeanInfo infor = server.getMBeanInfo(theName);
      

      getting the Exception:
      java.lang.reflect.UndeclaredThrowableException
       at $Proxy0.invoke(Unknown Source)
       at test.myIndipendend.main(myIndipendend.java:101)
      Caused by: java.io.NotSerializableException: org.jboss.mx.server.registry.MBeanEntry
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
      ...
      


      Some other ObjectName work as wanted! It is only on several Classes, that it does not work.
      As someone told me this is because of JMX 1.0, which has not implemented the Serialize-Interface for Remote calls.
      So my questions:
      - Is this right?
      - How can I access ALL Mbeans? It must be possible, as the JMX-Console does not seem to have problems with it.

      Best regards,
      Bastian

        • 1. Re: Question about
          Bastian Schaefer Newbie

          Hello,
          Excuse me, I described the wrong Exception:

          ObjectName theName = new ObjectName("jboss.jca:name=DefaultDS,service=ManagedConnectionFactory");
          MBeanInfo infor = server.getMBeanInfo(theName);
          

          throws the Exception:
          java.lang.reflect.UndeclaredThrowableException
           at $Proxy0.getMBeanInfo(Unknown Source)
           at test.myIndipendend.main(myIndipendend.java:92)
          Caused by: java.io.StreamCorruptedException: Null descriptor?
           at javax.management.modelmbean.DescriptorSupport.readObject(DescriptorSupport.java:538)
           at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          


          and the Operations-Invokation
          Integer into = (Integer)server.invoke(invokeName, "getSize",null,null);
          ObjectName[] names = {invokeName};
          String stringo = (String)server.invoke(invokeName, "get",names,new String[]{"javax.management.ObjectName"});
          

          throws
          java.lang.reflect.UndeclaredThrowableException
           at $Proxy0.invoke(Unknown Source)
           at test.myIndipendend.main(myIndipendend.java:101)
          Caused by: java.io.NotSerializableException: org.jboss.mx.server.registry.MBeanEntry
           at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
          ...
          


          The problem remains the same...

          Best regards,
          Bastian

          • 2. Re: Question about
            Dimitris Andreadis Master

            The jmx-console doesn't have a problem with non-serializable attribute values because it accesses them in the same jvm, so they are not serialized.

            • 3. Re: Question about
              Bastian Schaefer Newbie

              Thanks Dimitris.
              Is there any way for me to get the Attribute without serialization (without rmi).
              Best regards,
              bastian

              • 4. Re: Question about
                Dimitris Andreadis Master

                I believe this would work if the jboss jmx libraries are used (i.e. jdk1.4).

                • 5. Re: Question about
                  Bastian Schaefer Newbie

                  Hello,
                  This does not help me further.

                  I try do do something different now.

                  How can I use the mx4j HTTP-Adaptor with Jboss?
                  I am not able to register my http-Adaptor Bean as described in the mx4j Manual.

                  http://mx4j.sourceforge.net/docs/ch05.html

                  I use:

                  InitialContext ic = new InitialContext();
                   this.server = (RMIAdaptor) ic.lookup("jmx/invoker/RMIAdaptor");
                  


                  and then to register the http-adaptor:
                   ObjectName nameHttp = new ObjectName("Server:name=HttpAdaptor");
                   indi.server.createMBean("mx4j.tools.adaptor.http.HttpAdaptor", nameHttp, null);
                   server.setAttribute(nameHttp, new Attribute("Port", new Integer("8080")));
                   server.setAttribute(nameHttp, new Attribute("Host", "localhost"));
                   server.invoke(nameHttp, "start", null, null);
                  


                  getting the Excetion:

                  RuntimeErrorException: instantiating mx4j.tools.adaptor.http.HttpAdaptor failed: java.lang.NoClassDefFoundError: javax/management/MBeanRegistration
                  
                  Cause: java.lang.NoClassDefFoundError: javax/management/MBeanRegistration
                  
                  at org.jboss.mx.server.MBeanServerImpl.handleInstantiateExceptions(MBeanServerImpl.java:942)
                  
                  at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:875)
                  
                  at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:290)
                  
                  at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:267)
                  
                  at org.jboss.mx.server.MBeanServerImpl.createMBean(MBeanServerImpl.java:310)
                  
                  ...
                  
                  


                  Best regards

                  • 6. Re: Question about
                    Dimitris Andreadis Master

                    mx4j should have instructions of some sort, but in any case, this should be done on the server side either through proper packaging of the adaptor in a .sar, or if this is not possible through wrapping with a custom jboss mbean.