4 Replies Latest reply: Mar 23, 2008 5:14 AM by Vicky Kak RSS

    JBAS-5220 - Twiddle not displaying Platform MBean.

    Vicky Kak Master

      The MBeanServer which is passed to InvokerAdapterService is org.jboss.mx.server.MBeanServerImpl , this MBeanServer is created during LazyMBeanServer.resetToJBossServer(server) call in org.jboss.system.server.ServerImpl .
      The twiddle gets the MBean's which are registered in org.jboss.mx.server.MBeanServerImpl , the Platform MBean's are not registered in it.
      The InvokerAdapterService should have the reference of the LazyMBeanServer when this system property is set.

      -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl


      This can be done by making changes in InvokerAdapterService as
      Index: InvokerAdaptorService.java
      ===================================================================
      --- InvokerAdaptorService.java (revision 69558)
      +++ InvokerAdaptorService.java (working copy)
      @@ -43,6 +43,7 @@
       import org.jboss.jmx.adaptor.rmi.RMINotificationListener;
       import org.jboss.jmx.connector.invoker.client.InvokerAdaptorException;
       import org.jboss.mx.server.ServerConstants;
      +import org.jboss.system.server.jmx.LazyMBeanServer;
       import org.jboss.system.Registry;
       import org.jboss.system.ServiceMBeanSupport;
      
      @@ -263,6 +264,7 @@
       Class[] paramTypes = method.getParameterTypes();
       Method mbeanServerMethod = MBeanServer.class.getMethod(name,
       paramTypes);
      + server = LazyMBeanServer.getRegisteredMBeanServer(server);
       value = mbeanServerMethod.invoke(server, args);
       }
       }
      




        • 1. Re: JBAS-5220 - Twiddle not displaying Platform MBean.
          Scott Stark Master

          To properly propagate the LazyMBeanServer to all jboss mbeans in preRegister, the LazyMBeanServer has to be passed in to the MBeanServerImpl ctor as the outer argument. Its a one line change to do this in LazyMBeanServer.resetToJBossServer to pass the registeredServer:

           public static MBeanServer resetToJBossServer(MBeanServer server)
           throws Exception
           {
           MBeanServer coreServer = server;
           if( theDelegate != null )
           {
           Class[] sig = {String.class, MBeanServer.class, MBeanServerDelegate.class};
           Object[] args = {defaultDomain, registeredServer, theDelegate};
          


          With this change, I can use twiddle to query the platform mbeans:
          [starksm@succubus bin]$ twiddle.sh query 'java.lang:*'
          java.lang:type=Compilation
          java.lang:type=MemoryManager,name=CodeCacheManager
          java.lang:type=GarbageCollector,name=Copy
          java.lang:type=MemoryPool,name=Eden Space
          java.lang:type=Runtime
          java.lang:type=ClassLoading
          java.lang:type=MemoryPool,name=Survivor Space
          java.lang:type=Threading
          java.lang:type=GarbageCollector,name=MarkSweepCompact
          java.lang:type=OperatingSystem
          java.lang:type=Memory
          java.lang:type=MemoryPool,name=Code Cache
          java.lang:type=MemoryPool,name=Tenured Gen
          java.lang:type=MemoryPool,name=Perm Gen
          



          • 2. Re: JBAS-5220 - Twiddle not displaying Platform MBean.
            Vicky Kak Master

             

            [vicky@localhost bin]$ ./twiddle.sh query 'jboss.jca:*'
            13:56:16,758 ERROR [Twiddle] Exec failed
            org.jboss.util.NestedRuntimeException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory; - nested throwable: (javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory])
             at org.jboss.console.twiddle.Twiddle$1.getServer(Twiddle.java:143)
             at org.jboss.console.twiddle.command.MBeanServerCommand.getMBeanServer(MBeanServerCommand.java:59)
             at org.jboss.console.twiddle.command.MBeanServerCommand.queryMBeans(MBeanServerCommand.java:66)
             at org.jboss.console.twiddle.command.QueryCommand.execute(QueryCommand.java:138)
             at org.jboss.console.twiddle.Twiddle.main(Twiddle.java:305)
            Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
             at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
             at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
             at javax.naming.InitialContext.init(InitialContext.java:223)
             at javax.naming.InitialContext.<init>(InitialContext.java:175)
             at org.jboss.console.twiddle.Twiddle.createMBeanServerConnection(Twiddle.java:235)
             at org.jboss.console.twiddle.Twiddle.connect(Twiddle.java:268)
             at org.jboss.console.twiddle.Twiddle.access$300(Twiddle.java:62)
             at org.jboss.console.twiddle.Twiddle$1.getServer(Twiddle.java:139)
             ... 4 more
            Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
             at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
             at java.security.AccessController.doPrivileged(Native Method)
             at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
             at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
             at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
             at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
             at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
             at java.lang.Class.forName0(Native Method)
             at java.lang.Class.forName(Class.java:242)
             at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
             at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
             ... 11 more
            

            Twiddle seems to be broken on the truck , I just build the truck and am getting this exception .
            Can some one verify this ?


            • 3. Re: JBAS-5220 - Twiddle not displaying Platform MBean.
              Tobias Frech Apprentice

              Hi Vicky,
              I updated to the trunk version yesterday and can not confirm this. Testing on Linux here.

              But I am glad you found that error as well.

              I am not sure if that error should be fixed like this. Right now a domain either can be in the JBoss or the platform MBean server. Is that intended or just a side effect of the implementation.

              My guess would be, that "combining" the two MBean servers should really behave like there would be only one MBean server.

              Does the spec say anything about that? Is that covered at all?

              Ciao,
              Tobias

              • 4. Re: JBAS-5220 - Twiddle not displaying Platform MBean.
                Vicky Kak Master

                Hey Tobias,

                "Tobias" wrote:

                Is that intended or just a side effect of the implementation.

                The changes are yet not made in the trunk yet .
                Looks like this would go after I make the changes in trunk , I am going to make the changes today if I see this working
                [vicky@localhost bin]$ ./twiddle.sh query 'jboss.jca:*'


                Vicky