I am trying to get a server connection to a remote MBean Server. I am using the following code:
MBeanServerConnection server = null;
Hashtable env = new Hashtable();
InitialContext ic = new InitialContext(env);
server = (RMIAdaptor) ic.lookup("jmx/invoker/RMIAdaptor");
When running the code on one of the remote servers I get a java.lang.ClassCastException on the lookup which is strange because RMIAdaptor actually extends the MBeanServerConnection. I think it is something else. When I run this code on my desktop against my local machine it works fine. But when I run this code on my local machine against a remote server I get a javax.nameing.CommunicationException.
Any help on how to query the Mbeans on a remote machine would be helpful?
FYI this code worked fine in all aspects with jboss 4.0.3 it is 4.0.4 that is giving me the problems.
See this http://wiki.jboss.org/wiki/Wiki.jsp?page=HowDoIGetRemoteAccessToMyMBean. It says that
Note: Use the MBeanServerConnection interface rather than RMIAdaptor on the most recent versions of JBoss.