7 Replies Latest reply: Nov 9, 2012 7:40 AM by Ravi Samavedula RSS

InitialContext.lookup returns null

MUHAMMAD RAHMAN Newbie

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
    jaikiran pai Master

    What are you looking up?

  • 2. Re: InitialContext.lookup returns null
    Peter Johnson Master

    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
    MUHAMMAD RAHMAN Newbie

    In my jndi.properties file I have written as follows

    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    java.naming.provider.url=jnp://192.168.1.104:1099
    java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

    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
    Peter Johnson Master

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

    telnet 192.168.1.104 1099

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

    UnicastRef2192.59.193.104?Jsëk½?ñ#·gÇx

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

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

    Example:

    192.168.1.104 linuxbox1 linuxbox1.cox.net


  • 5. Re: InitialContext.lookup returns null
    MUHAMMAD RAHMAN Newbie

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

  • 6. Re: InitialContext.lookup returns null
    Guillaume Soing Newbie

    Hello,

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

    Thanks

    Delphine

  • 7. Re: InitialContext.lookup returns null
    Ravi Samavedula Newbie

    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/192.168.1.46:11099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server R2SP11/192.168.1.46:11099 [Root exception is java.net.ConnectException: Connection refused: connect]]]

     

    I am getting something like this R2SP11/192.168.1.46

     

    Thanks