7 Replies Latest reply on Nov 9, 2012 7:40 AM by samavedulark

    InitialContext.lookup returns null


      My jboss is in linux machine and my client application is running in a windows machine. The problem is from my java client application initialContext.lookup method returns null

        • 1. Re: InitialContext.lookup returns null

          What are you looking up?

          • 2. Re: InitialContext.lookup returns null

            Also, do you have a firewall on the Linux machine? If so make sure you open the ports 1098, 1099, 4443 and 4444 (or their equivalents if you changed the port settings). The last two you might not need unless you are accessing mbeans.

            • 3. Re: InitialContext.lookup returns null

              In my jndi.properties file I have written as follows


              My client program is as follows

              1. Properties prop=new Properties(new FileInputStream("jndi.properties"));
              2. InitialContext context=new InitialContext(prop);
              3. Object obj=context.lookup("MyEjb");

              Line 1 and 2 has no problem, but in line 3 when I look up my ejb in server it returns null. I am not using any firewall and my necessary ports are open.

              When I run my java client program in linux machine where my JBoss server is located then no problem occurs.

              • 4. Re: InitialContext.lookup returns null

                Try this. Enter the following at a command prompt on Windows:

                telnet 1099

                The last line of the response shpould have an IP address in it. On my PC it looks like:


                If the IP address does not match that of your Linux box, add the following line to your /etc/hosts file:

       <simple-pc-name> <pc-name-with-full-domain>


       linuxbox1 linuxbox1.cox.net

                • 5. Re: InitialContext.lookup returns null

                  My problem has been solved.
                  Thanks to everyone for giving me the solution.

                  • 6. Re: InitialContext.lookup returns null


                    I have the same problem. How did you solve it?



                    • 7. Re: InitialContext.lookup returns null

                      Hi Peter,


                      I have the same issue, and in log file i am getting some thing like this.

                      Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: R2SP11:11099 [Root exception is javax.naming.CommunicationException: Failed to connect to server R2SP11/ [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server R2SP11/ [Root exception is java.net.ConnectException: Connection refused: connect]]]


                      I am getting something like this R2SP11/