当我尝试使用以下代码从代理(activemq)中删除一个队列时,我收到了类似Instancenotfound exception.code的错误
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url);
MBeanServerConnection conn = jmxc.getMBeanServerConnection();
String operationName="removeQueue";
String parameter="PostWithParameter_Queue"; //am given queue name
ObjectName activeMQ = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Broker");
if(parameter != null) {
Object[] params = {parameter};
String[] sig = {"java.lang.String"};
conn.invoke(activeMQ, operationName, params, sig);
} else {
conn.invoke(activeMQ, operationName,null,null);
}
我得到的确切错误如下所示
Exception in thread "main" javax.management.InstanceNotFoundException: org.apache.activemq:BrokerName=localhost,Type=Broker
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getClassLoaderFor(Unknown Source)
at com.sun.jmx.mbeanserver.JmxMBeanServer.getClassLoaderFor(Unknown Source)
我从下面的链接中得到了这个代码
http://www.consulting-notes.com/2010/08/monitoring-and-managing-activemq-with.html
如果不清楚,请通过此链接。谢谢提前