I have two nodes(n1, n2) running the all configuration with HAJNDI service enabled. The org.jboss.ha.jndi.HANamingService mbean in cluster-service.xml has the default configuration. I'm using jboss-4.0.3SP1.
I have the following source code to remotely access the mbean server via RMIAdaptor:
// initial context
Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
jndiProperties.put(Context.PROVIDER_URL, jnp://n1:1099);
jndiProperties.put(Context.URL_PKG_PREFIXES, jboss.naming:org.jnp.interfaces");
//jndiProperties.put("jnp.disableDiscovery", "true");
InitialContext ic = new InitialContext(jndiProperties);
// connecting to mbean server
MBeanServerConnection server = (MBeanServerConnection) ic.lookup("jmx/invoker/RMIAdaptor");
//get host info
ObjectName name = new ObjectName("jboss.system:type=ServerInfo");
System.out.println("Host name: " + server.getAttribute(name, "HostName"));
I got inconsistent output, it might be
Host name: n1, or
Host name: n2
Even I uncomment out
//jndiProperties.put("jnp.disableDiscovery", "true");
it still gave inconsistent output.
Is this expected behavior? And how can I get a reference to the RMIAdaptor for the node n1 consistently?
Please help. Thanks.