Re: RmiConnectorServer Problem
you must start $JAVA_HOME/bin/rmiregistry 2099 &
then you mast change the code in JMXBookAgent class
/*---------------------------------------------------------------------------------------------*/
protected void startRMIConnector() {
try {
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:2099/server");
JMXConnectorServer cs = JMXConnectorServerFactory
.newJMXConnectorServer(url,
null,
server);
cs.start();
} catch(Exception e) {
printException(e);
}
}
/*---------------------------------------------------------------------------*/
then change the class RMIClientFactory
public static MBeanServerConnection getClient() {
try {
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:2099/server");
JMXConnector jmxc = JMXConnectorFactory.connect(url,
null);
return jmxc.getMBeanServerConnection();
} catch(MalformedURLException e) {
ExceptionUtil.printException( e );
} catch(IOException e) {
ExceptionUtil.printException( e );
}
return null;
}
/*---------------------------------------------------------------------------------------------*/
and finally change the costructor of HelloWorldSetup class
try {
MBeanServerConnection client = RMIClientFactory.getClient();
ObjectName hwName = new ObjectName("JMXBookAgent:name=helloWorld");
client.createMBean("ch2.HelloWorld",
hwName);
client.invoke(hwName,
"printGreeting",
null,
null);
} catch(Exception e) {
e.printStackTrace();
}
|