8 Replies Latest reply on Oct 1, 2009 8:33 PM by Wylie van den Akker

    JNDI lookup for object in remote server returns local object

    Etienne Labuschagne Newbie

      I have a setup consisting of multiple machines, each running JBoss in a non-clustered setup. Clients all connect to one JBoss Master and that decides which of the other JBoss Nodes to use (Nodes):

      Client - JBoss Master -- JBoss Node1
       -- JBoss Node2
       -- JBoss Node3

      (The above may not format nicely, but the concept is one client connects to one JBoss Master connects to many JBoss Nodes)

      The Master JBoss may also act as a Node.

      I use the following code to get to a Stateless Session bean in one of the nodes

      String ipAddress = getNodeIPAddress();
      Properties properties = new Properties();
      properties.put("java.naming.provider.url",String.format("%s:1099", ipAddress));
      Context context;
      context = new InitialContext(properties);
      NodeRemote remote = (NodeRemote) context.lookup("node_ear/Node/remote");

      1) If I don't deploy node_ear into JBoss Master, it works fine. The remote object is bound to whichever remote JBoss Node's IP address was given.
      2) If I do deploy node_ear into JBoss Master (in my case, the Master can also be a Node) then I get a locally bound NodeRemote object. It seems once an initial context object is created for the local context, I cannot get a remote context.

      I am admittedly very new to JEE programming and JNDI concepts and am probably making a very fundamental mistake. I have searched around for an answer, but I may be searching for the wrong things.

      Any help or pointers to help would be most appreciated!