1 Reply Latest reply on Jul 5, 2007 11:34 AM by Javier Comín

    Refresh values in HAJNDI object

    Javier Comín Newbie

      I have an application working in a cluster environment (two nodes) with JBoss 4.0.4.
      This app haves a shared object (a bean) in HAJNDI that works as follow:

      The master node sets some values (monitoring values) in this bean and as HAJNDI works, this object will be gathered by the other replicated application in cluster. If I want to refresh monitor values from master node, I can do it (I mean, all values are set to zero and the other replicated app in cluster can see refreshed values)
      But, JBoss is working in a rare way if I do this from the other node or I don't understand very well how HAJNDI works.
      Because, if this process (set all values to zero) is made in the other node, I can see refreshed values in this node only and I can't see refreshed values from the master node.
      The question is...why ONLY from the master node I can refresh bean values in HAJNDI? Why not from the other node in cluster?

      I have a object (a bean called "transactionInfoBean") published in a HAJNDI tree with this code:

      ...
      p.load(new FileInputStream(new File(path + "/hajndi.properties")));
      ...
      try {
      lookup.bind("cluster/beans/" + "transactionInfoBean", transactionInfoBean);
      } catch (NameAlreadyBoundException e) {
      lookup.rebind("cluster/beans/" + "transactionInfoBean", transactionInfoBean);
      }
      ...


      perform some works...

      // obtains the remote bean and invokes its refreshStoreCounters() method.
      transactionInfoBean = (TransactionInfoBean) lookup.get("cluster/beans/transactionInfoBean");
      transactionInfoBean.refreshStoresCounters(localStoreMonitors);
      lookup.rebind("cluster/beans/transactionInfoBean", transactionInfoBean);


      hajndi.properties file content
      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.factory.url.pkgs=org.jnp.interfaces
      java.naming.provider.url=localhost:1100

        • 1. Re: Refresh values in HAJNDI object
          Javier Comín Newbie

          The trouble was the "Lookup" object. It was not working well. As this was an internal developed object, I replaced the lookup by this code that I found in "SACHA LABOUREY, BILL BURKE The JBoss Group JBoss AS Clustering" book.
          ...
          Properties p = new Properties();
          p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
          p.put(Context.PROVIDER_URL, "localhost:1100"); // HA-JNDI port.
          initialContext = new InitialContext(p);
          ....

          then I do
          initialContext.bind()...
          initialContext.rebind()...

          and it is working well.