0 Replies Latest reply on Jul 11, 2005 11:00 AM by Klaus Schroeder

    HA JNDI mixed up?

    Klaus Schroeder Newbie

      I have a problem with cluster (HA) JNDI lookups in JBoss 4.0.1SP1.

      We start 2 RMI based services and bind them in JNDI using the following code

      String partitionName = System.getProperty(PROP_JBOSS_PARTITION, DEFAULT_JBOSS_PARTITION_NAME);
      InitialContext context = new InitialContext();
      // ...
      context.bind("TLDServerWorking", rmiServerWorking);
      ...
      context.bind("TLDServerLive", rmiServerLive);
      


      Some other applications running in the same JBoss cluster partition should lookup this RMI server using the following code:

      Properties props = new Properties();
      props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      props.setProperty("java.naming.provider.url", "jnp://localhost:8282/"); // HA JNDI port
      InitialContext rpcContext = new InitialContext(props);
      // ...
      this.RMIServer = (FTRMIServer) rpcContext.lookup(name);
      


      So we bind the services using the local JNDI tree and we do the lookup using the HA JNDI tree. Fro all documentation we found so far, this seems to be the way to do it in a clustered JBoss. Please correct me, if I am wrong.

      We already saw this code working, but this seems to be quite instable. Sometimes (in most cases) the lookup fails with NameNotFound.

      To track down the problem we used twiddle to view the JNDI trees and this shows very strange effects. You get different results if you call it multiple times:

      First call:
      >twiddle.bat -s localhost:8382 invoke "jboss:service=JNDIView" list true
      ...
      <h1>Global JNDI Namespace</h1>
      <pre>
       +- TLDServerLive (class: com.poet.xs.tld.server.RMIServer)
       +- jmx (class: org.jnp.interfaces.NamingContext)
       | +- invoker (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor (proxy: $Proxy13 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt,interface org.jboss.proxy.IClientContainer)
       | +- rmi (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
       +- HAPartition (class: org.jnp.interfaces.NamingContext)
       | +- EC_1120654668872 (class: org.jboss.ha.framework.server.HAPartitionImpl)
       +- HASessionState (class: org.jnp.interfaces.NamingContext)
       | +- Default (class: org.jboss.ha.hasessionstate.server.HASessionStateImpl)
      </pre>
      


      Later call:
      >twiddle.bat -s localhost:8382 invoke "jboss:service=JNDIView" list true
      ...
      <h1>Global JNDI Namespace</h1>
      <pre>
       +- TLDServerLive (class: com.poet.xs.tld.server.RMIServer)
       +- jmx (class: org.jnp.interfaces.NamingContext)
       | +- invoker (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor (proxy: $Proxy13 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt,interface org.jboss.proxy.IClientContainer)
       | +- rmi (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
       +- TLDServerWorking (class: com.poet.xs.tld.server.RMIServer)
       +- HAPartition (class: org.jnp.interfaces.NamingContext)
       | +- EC_1120654668872 (class: org.jboss.ha.framework.server.HAPartitionImpl)
       +- HASessionState (class: org.jnp.interfaces.NamingContext)
       | +- Default (class: org.jboss.ha.hasessionstate.server.HASessionStateImpl)
      </pre>
      



      Can anybody give me an explanation for this?
      Something to check in the configuration?

      Thanks for any help.

      /Klaus