可以使用RMI连接到JMX吗?我测试出了问题.测试代码大致如下:
public static void main(String[] args) throws Exception {
// Get RMIAdaptor Object
Properties pro = new Properties();
pro.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
pro.setProperty("java.naming.provider.url", "jnp://localhost:1099");
pro.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
InitialContext ic = new InitialContext(pro);
RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/invoker/RMIAdaptor");//
// Get the MBeanInfo for the JNDIView MBean
ObjectName name = new ObjectName("JMX_TEST:service=HelloWorld");//这是某中一个MBean,
MBeanInfo info = server.getMBeanInfo(name);//得到对象
}
启动Minimal服务,执行这代码会抛出异常:
Exception in thread "main" javax.naming.NameNotFoundException: jmx not bound
如果我启动default的服务,执行这测试代码的话就没问题.
请问这问题出在哪里呢?请指教!