Reputation: 321
Basically I am following the standard basic JMX tutorial and registering a MXBean with two methods.
public interface QueueSamplerMXBean {
public QueueSample getQueueSample();
public void clearQueue();
}
However, when I try to query the registered MBean, it only returns the clearQueue. Here is my sample program:
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
// Construct the ObjectName for the QueueSampler MXBean we will register
ObjectName mxbeanName = new ObjectName("com.example:type=QueueSampler");
// Create the Queue Sampler MXBean
Queue<String> queue = new ArrayBlockingQueue<String>(10);
queue.add("Request-1");
queue.add("Request-2");
queue.add("Request-3");
QueueSampler mxbean = new QueueSampler(queue);
// Register the Queue Sampler MXBean
mbs.registerMBean(mxbean, mxbeanName);
MBeanInfo info = mbs.getMBeanInfo(mxbeanName);
for(MBeanOperationInfo op : info.getOperations()) {
System.out.println("operation = " + op.getName());
}
I think this is the reason why I keeps getting "java.lang.IllegalArgumentException. ... No operation XXXXXX(method name invoked) found on MBean ..... I am getting this exception while trying to invoke the MXBean method through Jolokia agent (JSON to JMX bridge). I have no problem invoking methods with void return type.
Anyone have any clues why getOperations does NOT return me the method with an JavaBean object as a return type? This is so weird. I must be missing something really simple.
Thanks!
Upvotes: 2
Views: 1610
Reputation: 30994
I bet you have an attribute queueSample
on your MBean instead, as getFoo
is usually turned in to a readable attribute foo
, setFoo
into a writable one and if you have getter and setter, the attribute is r/w.
Use a tool like jconsole
to connect to the VM and inspect your MBean.
Upvotes: 1
Reputation: 16066
The method should be:
public QueueSampleMBean getQueueSample();
And QueueSample should implement QueueSampleMBean (and only expose simple types).
Upvotes: 0