Hello!

I'm trying to access a HA Singleton MBean from session EJBs but experiencing a problem 
which really makes me ill.  First the EJB looks up the RMIAdaptor:


  | Properties properties = new Properties();
  | properties.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
  | properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
  | properties.put(Context.PROVIDER_URL, "jnp://localhost:1100");
  | try
  | {
  |     Context context = new InitialContext(properties);
  |     Object o = context.lookup("jmx/invoker/RMIAdaptor");
  |     mbeanServer = new RMIConnectorImpl((RMIAdaptor) o);
  | }
  | catch (NamingException e)
  | {
  |     handleException(e);
  | }
  | 


Then I test wheter the singleton service is registered before invoking methodes on the 
service:


  | ObjectName name = new ObjectName("myDomain:service=MyService");
  | Boolean ok = mbeanServer.isRegistered(name);
  | if (ok)
  | {
  |        Object result = mbeanServer.invoke(...);
  | }
  | 

The problem is on the nodes which are currently not master. As expected 
"isRegistered()" returns false and I can't invoke the MBean. On the node which is 
master everything works fine.
And now, most incomprehensible to me is that nearly the same code put in a simple test 
class works really ok:


  | String port = "1100";
  | String[] clusterMembers = {"192.168.2.10", "192.168.2.25", "192.168.2.30"};
  | ObjectName name = new ObjectName("myDomain:service=MyService");
  | RemoteMBeanServer server = null;
  | int i = 0;
  | while (i < hosts.length)
  | {
  |     properties.put(Context.PROVIDER_URL, "jnp://" + hosts + port);
  |     Context context = new InitialContext(properties);
  |     Object o = context.lookup("jmx/invoker/RMIAdaptor");
  |     server = new RMIConnectorImpl((RMIAdaptor) o);
  |     if (server.isRegistered(name))
  |     {
  |             System.out.println(i + " " + clusterMembers + " " + 
server.isRegistered(name));
  |             System.out.println(server.getAttribute(name, "MasterNode").toString());
  |     }
  |     i++;
  | }
  | 

For every loop the isRegistered() returns true and "MasterNode" is also true. The 
conclusion to me is that for the EJB I get somthing like a "local" RMIAdaptor with the 
HA singleton service available only on the master node. For the test class, started in 
another VM, I always get something like a "global" RMIAdaptor with the HA singleton 
service available.
Is that correct? Or do I completely mixed something up.

And most importantly: What is the "safe" way to access HA singleton MBean from EJBs.

(Please note that all the nodes really build ONE cluster, i.e. they find each other 
and I can see messages on the console telling me that too.)

Thanks a lot for your answers.

Oh, I forgot to say that I use V3.2.6RC1.

Thorsten

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3845358#3845358

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3845358


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to