Question

I am trying to publish an MXBean to JMX but I am getting the following stack when I start the program and the bean is being published:

Caused by: java.io.InvalidObjectException: Do not know how to make a javax.management.openmbean.CompositeType from a CompositeData: no method from(CompositeData); no constructor has @ConstructorProperties annotation; does not have a public no-arg constructor; not an interface
        at com.sun.jmx.mbeanserver.OpenConverter.invalidObjectException(OpenConverter.java:1403)
        at com.sun.jmx.mbeanserver.OpenConverter$CompositeConverter.makeCompositeBuilder(OpenConverter.java:891)
        at com.sun.jmx.mbeanserver.OpenConverter$CompositeConverter.checkReconstructible(OpenConverter.java:897)
        at com.sun.jmx.mbeanserver.OpenConverter$CompositeBuilderCheckGetters.applicable(OpenConverter.java:1034)
        at com.sun.jmx.mbeanserver.OpenConverter$CompositeConverter.makeCompositeBuilder(OpenConverter.java:868)
        ... 48 more

Now I now that MXBeans are only supposed use OpenMbean types as per the documentation but my class is only using java.lang.String and javax.management.openmbean.CompositeData, so I do not know why it is failing. The interface is:

import javax.management.MXBean;
import javax.management.openmbean.CompositeData;

@MXBean
public interface JmxAdministrationApi {

    String synchronize(CompositeData clientInfo);

}

It is worth noting that the bean was being published correctly until I added the CompositeData parameter (i.e. with no parameters), and only then did this error occur.

Any help with this would be greatly appreciated.

Thanks in advance,

Rob

Edit: also, we are using Spring JMX

Was it helpful?

Solution

You shouldn't be using CompositeData directly even though the documentation sounds like you should. The MXBean will take care of converting a proprietary data type into a CompositeData instance and back automatically.

Take a look at the samples provided in the documentation to see how you should use @ConstructorProperties annotation to make your data type play nicely with composite data and MXBeans.

-JB-

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top