我試圖從我的Spring應用程序連接到MBean服務器。以下是代碼:InvocationException從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?