Creating MBean in Java

Having just encountered this exception and looked at the current answers as well as https://blogs.oracle.com/jmxetc/entry/javax_management_standardmbean_when_and I thought it might help to emphasize and clarify the following already elucidated to:

  1. The NotCompliantMBeanException is caused, among other things, by failing to follow this convention 'ConcreteClassName' implements 'ConcreteClassNameMBean'

  2. I resolved this by updating the original name of my mbean interface from 'OrignalNameMBean' to 'OriginalNameMXBean' allowing the mbean to be registered without following the convention

  3. Another solution would be to follow the convention.


The implementing mbean class can declare as many methods as it likes that are not defined in mbeans interface... There is no requirement that the implementing class can/must only implement the interface methods.

In many of the cases this problem is caused because the mbean interface and implementation class are not in the same package!


I had the same issue ("does not implement DynamicMBean, and neither follows the Standard MBean conventions") and this article helped me to resolve the problem (see Using StandardMBean section: https://blogs.oracle.com/jmxetc/entry/javax_management_standardmbean_when_and).

I have to explicitly construct a

StandardMBean mbean = new StandardMBean(mBeanImpl, MBeanInterface.class);

then register the mbean:

mbServer.registerMBean(mbean, mBeanName);

It works.

When I register the mBeanImpl with the mbServer, I got the above exception.

Tags:

Java

Jmx

Mbeans