I'm fairly sure that I'm doing something stupid here, but I can't find anything that indicates exactly what it is. I'm trying to use an MBeanServer to look up an MBean, but can't seem to get a valid ObjectName. For example:
MBeanServer server = MBeanServerFactory.createMBeanServer();
ObjectName name = new ObjectName("jboss:name=SystemProperties,type=service");
String state = (String) server.getAttribute(name,"StateString");
always throws the following exception:
23:39:17,642 ERROR [STDERR] javax.management.InstanceNotFoundException: jboss:name=SystemProperties,type=service is not registered.
23:39:17,642 ERROR [STDERR] at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:403)
23:39:17,642 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.getAttribute(MBeanServerImpl.java:387)
and yet if I go and browse via the jmx-console, I can see that the properties service is there, and it's stateString is "started".
Can someone please hit me with the clue-stick?
MBeanServer server = MBeanServerFactory.findMBeanServer().iterator().next();