【发布时间】:2013-05-02 11:37:01
【问题描述】:
我正在尝试从我的 Spring 应用程序连接到 MBean 服务器。下面是代码:
public void connect() throws Exception {
MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean();
bean.setConnectOnStartup(false);
Properties environment = new Properties();
environment.put("java.naming.factory.initial", "com.sun.jndi.rmi.registry.RegistryContextFactory");
environment.put("java.naming.provider.url", "rmi://117.13.128.104:9308");
environment.put("jmx.remote.jndi.rebind", "true");
bean.setEnvironment(environment);
bean.setServiceUrl("service:jmx:rmi://117.13.128.104/jndi/rmi://117.13.128.104:9308/agent/EODServer");
bean.afterPropertiesSet();
MBeanServerConnection server = (MBeanServerConnection)bean.getObject();
System.out.println("test"); // After bean.getObject() - Debug pointer on this line.
}
在 bean.getObject() 方法调用后设置调试指针。
在调试上述代码时,我得到的 MBeanServerConnection 服务器值低于:
com.sun.jdi.InvocationException 发生调用方法。
MBeanServerConnectionFactoryBean的Environment和ServiceUrl的值设置正确,为什么它没有连接到MBean Server?
【问题讨论】: