8 Replies Latest reply on Oct 1, 2009 8:33 PM by nakker

    JNDI lookup for object in remote server returns local object

    delabu

      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.factory.initial","org.jnp.interfaces.NamingContextFactory");
      properties.put("java.naming.factory.url.pkgs","=org.jboss.naming:org.jnp.interfaces");
      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!

        • 1. Re: JNDI lookup for object in remote server returns local ob
          waynebaylor

          where is the lookup code located? application client (with a main method), in a servlet/jsp, etc.?

          • 2. Re: JNDI lookup for object in remote server returns local ob
            delabu

            The lookup code is in a Stateless Session Bean in the JBoss Master. So, in my diagram, it's in the "middle" section.

            This Statless Session Bean has to look up the Stateless Session Bean in one of the remote nodes and do a call to that.

            The sequence is thus:

            1. Client (eg. command line) looks up Master Stateless Session Bean and calls it.
            2. Master Stateless Session Bean looks up Node Stateless Session Bean (which can be on the local JBoss, but usually in another Node JBoss) and calls that.

            The lookup code in 2. always returns a local instance of Node Stateless Session Bean even though the lookup specified a remote Node JBoss's IP address and I wanted a remote proxy to the Node Stateless Session Bean on the remote Node JBoss.

            Thanks.

            • 3. Re: JNDI lookup for object in remote server returns local ob
              waynebaylor

              just to make sure, when you deploy the ear to the Master Node it is also deployed to other Nodes right?

              i wouldn't be suprised if when the remote lookup fails the local context is then checked.

              • 4. Re: JNDI lookup for object in remote server returns local ob
                delabu

                The deployments seems ok as far as I can acertain. When I undeploy the Node ear from the Master jboss, the lookup to the remote Node works perfectly.

                If there was a problem with it not getting the remote instance, it should have produced an error in this case. But it gets the remote instance and executes without problem.

                Interesting thing is, starting Master JBoss without the node causes getting the remote Node. Hot deploying Node into master, still get remote node. Restart JBoss and I get the local Node again, not master. It's as if once I get a context, it doesn't get re-created, even though I did acquire a new context. Is it possible that the Context is a Singleton and that subsequent retrieval of contexts always return the same instance, regardless of the parameters I pass when asking for the context?

                • 5. Re: JNDI lookup for object in remote server returns local ob
                  delabu

                  I have created a test project that recreates this behaviour. If anyone is interested, I can send it or upload it somewhere.

                  • 6. Re: JNDI lookup for object in remote server returns local ob
                    subo2008

                    Is there any solution or workaround available regarding this problem?
                    Nearly one year later, I'm facing the same issue with JBoss 4.2.3.GA.

                    Thanks,
                    Sven

                    • 7. Re: JNDI lookup for object in remote server returns local ob
                      delabu

                      Sadly I have never managed to get an anwer to this problem. We have resorted to changing our whole layout of servers and then get by by not deploying the relevant code on the "master" node. It means that those can only be accessed at the remote nodes and the resolution of those reserver work correctly.

                      I hope you have more luck in finding a solution and would be grateful if you can post it here should you get one!

                      Etienne

                      • 8. Re: JNDI lookup for object in remote server returns local ob
                        nakker

                        Have you tried

                        properties.put("jnp.disableDiscovery", "true");


                        Worked for me in a similar situation. This property forces the connection to only connect to the specified server and no one else (including self). It does have clustering implications you need to examine though.