5 Replies Latest reply: Sep 8, 2010 3:50 AM by PhHein RSS

    javax.management.NotCompliantMBeanException: MBean class

    843798
      Dears,
      I am getting exception in the line: server.registerMBean(this, name);. Please help me to solve this problem.


      My code is:
      System.out.println("1");
      name = new ObjectName("Application:Name=WebQuote,Type=/WebQuote");
      System.out.println("2");
      server.registerMBean(this, name);
      System.out.println("3");

      Here is the exception:

      1
      2
      javax.management.NotCompliantMBeanException: MBean class com.arrowasia.wq.manage
      r.ServerManager does not implement DynamicMBean, neither follows the Standard MB
      ean conventions (javax.management.NotCompliantMBeanException: Class com.arrowasi
      a.wq.manager.ServerManager is not a JMX compliant Standard MBean) nor the MXBean
      conventions (javax.management.NotCompliantMBeanException: com.arrowasia.wq.mana
      ger.ServerManager: Class com.arrowasia.wq.manager.ServerManager is not a JMX com
      pliant MXBean)
      at com.sun.jmx.mbeanserver.Introspector.checkCompliance(Introspector.jav
      a:160)
      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(D
      efaultMBeanServerInterceptor.java:305)
      at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.j
      ava:482)
      at com.arrowasia.wq.manager.ServerManager.<init>(ServerManager.java:21)
      at com.arrowasia.wq.manager.WebQuoteContextListener.contextInitialized(W
      ebQuoteContextListener.java:12)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
      t.java:3830)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
      337)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
      .java:791)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
      1)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)

      at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.ja
      va:626)
      at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.j
      ava:553)
      at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488
      )
      at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
      at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
      :311)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
      eSupport.java:117)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)

      at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)

      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443
      )
      at org.apache.catalina.core.StandardService.start(StandardService.java:5
      16)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:710
      )
      at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
      Apr 25, 2008 2:30:31 PM org.apache.coyote.http11.Http11Protocol start
      INFO: Starting Coyote HTTP/1.1 on http-80
      Apr 25, 2008 2:30:32 PM org.apache.jk.common.ChannelSocket init
      INFO: JK: ajp13 listening on /0.0.0.0:8009
      Apr 25, 2008 2:30:32 PM org.apache.jk.server.JkMain start
      INFO: Jk running ID=0 time=0/94 config=null
      Apr 25, 2008 2:30:32 PM org.apache.catalina.startup.Catalina start
      INFO: Server startup in 2938 ms
        • 1. Re: javax.management.NotCompliantMBeanException: MBean class
          800572
          You need to show us what the class of
          this
          is in
          registerMBean(this, name)
          . The exception is saying that this class is not a valid MBean class.

          Regards,
          �amonn McManus -- JMX Spec Lead -- http://weblogs.java.net/blog/emcmanus
          • 2. Re: javax.management.NotCompliantMBeanException: MBean class
            843798
            I'm also getting the same exception. I'm trying to run the code from JDK samples.

            Here is the code.....

            package com.example.mbeans;
            import java.lang.management.*;
            import javax.management.*;
            public class Main {

            public static void main(String[] args) throws Exception {
                 // Get the Platform MBean Server
                 MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
            System.out.println(" Platform mbean server");
                 // Construct the ObjectName for the MBean we will register
                 ObjectName name = new ObjectName("com.example.mbeans:type=Hello");
                 System.out.println("Object Created");
                 // Create the Hello World MBean
                 Hello mbean = new Hello();
                 // Register the Hello World MBean
                 mbs.registerMBean(mbean, name);
                 // Wait forever
                 System.out.println("Waiting forever...");
                 Thread.sleep(Long.MAX_VALUE);
            }
            }

            The Interface ....
            public interface HelloMbean {
            public int add(int x, int y);
            public int getCacheSize();
            public String getName();
            public void sayHello();
            public void setCacheSize(int size);
            }
                 
            The class .......     
                 
            public class Hello implements HelloMbean {
            // constructor
                 public Hello() {
                      System.out.println("hello object created");
                 }
                 private static final int DEFAULT_CACHE_SIZE = 200;
            private final String name = "Reginald";
            private int cacheSize = DEFAULT_CACHE_SIZE;
            public int add(int x, int y) {
                 return x + y;
            }
            // geters
            public int getCacheSize() {
                 return this.cacheSize;
            }
            public String getName() {
                 return this.name;
            }
            public void sayHello() {
                 System.out.println("hello, world");
            }
            // Setter
            public synchronized void setCacheSize(int size) {
                 this.cacheSize = size;
                 System.out.println("Cache size now " + this.cacheSize);
            }
            }

            The example didn't had any constructor, I tried after adding one, but still the same error!
            Just can't figure out the problem!

            regards
            CD
            • 3. Re: javax.management.NotCompliantMBeanException: MBean class
              843798
              figured it out! silly mistake!

              Problem was in the declaration...

              public interface HelloMbean {
              Should be... public interface HelloMBean {

              regards
              CD
              • 4. Re: javax.management.NotCompliantMBeanException: MBean class
                843798
                I am getting the same exception "javax.management.NotCompliantMBeanException".
                In my case this is happining becouse of different package. I have "HelloMBean" in "com.interfaces" package while my implementaion class "Hello" is in different package "com.impl" . It is throwing "javax.management.NotCompliantMBeanException" exception on registering the MBean as it is searching the interface in same package (com.impl). I am clueless why it is searchinh interface in same package.


                So if you have interface and implementation in different package then try once by shifting your interface to package of implementation.
                For any query revert.
                • 5. Re: javax.management.NotCompliantMBeanException: MBean class
                  PhHein
                  Welcome to the forum. Please don't post in threads that are long dead and don't hijack other threads. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.

                  I'm locking this thread now.