I have types like this:
public interface Numbering { List<NumberingComponent> getComponents(); } public interface NumberingComponent { Object getValue(); } public interface StringNumberingComponent extends NumberingComponent { String getValue(); } public interface IntegerNumberingComponent extends NumberingComponent { Integer getValue(); }
This is all good and good, unless you try to register an MXBean that uses this type, and you get:
... top of exception chain omitted ...
Caused by: javax.management.openmbean.OpenDataException: Cannot convert type: class com.acme.NumberingComponent
at com.sun.jmx.mbeanserver.OpenConverter.openDataException (OpenConverter.java:1411)
at com.sun.jmx.mbeanserver.OpenConverter.toConverter (OpenConverter.java:264)
at com.sun.jmx.mbeanserver.OpenConverter.makeArrayOrCollectionConverter (OpenConverter.java data15)
at com.sun.jmx.mbeanserver.OpenConverter.makeParameterizedConverter (OpenConverter.javahaps93)
at com.sun.jmx.mbeanserver.OpenConverter.makeConverter (OpenConverter.java:296)
at com.sun.jmx.mbeanserver.OpenConverter.toConverter (OpenConverter.java:262)
... 57 more
Caused by: javax.management.openmbean.OpenDataException: Cannot convert type: interface java.io.Serializable
at com.sun.jmx.mbeanserver.OpenConverter.openDataException (OpenConverter.java:1411)
at com.sun.jmx.mbeanserver.OpenConverter.toConverter (OpenConverter.java:264)
at com.sun.jmx.mbeanserver.OpenConverter.makeCompositeConverter (OpenConverter.java:467)
at com.sun.jmx.mbeanserver.OpenConverter.makeConverter (OpenConverter.java:293)
at com.sun.jmx.mbeanserver.OpenConverter.toConverter (OpenConverter.java:262)
... 61 more
Caused by: javax.management.openmbean.OpenDataException: Can't map java.io.Serializable to an open data type
at com.sun.jmx.mbeanserver.OpenConverter.makeCompositeConverter (OpenConverter.java:454)
at com.sun.jmx.mbeanserver.OpenConverter.makeConverter (OpenConverter.java:293)
at com.sun.jmx.mbeanserver.OpenConverter.toConverter (OpenConverter.java:262)
... 64 more
Strings and integers are represented in JMX, but Object is not, since at least one getter must be present in the class so that it recognizes it as a useful type. I know that any attempt to add an abstraction layer will not help, because NumberingComponent itself is already such a layer. The original version of the interfaces also had generics, but I removed them to simplify them, and it fails in the same way with or without them.
Is there any other way that I can do by matching this with a composite type? I googled an exception message and didn't get any hits at all. (!!)
source share