1 Reply Latest reply on Dec 10, 2012 5:49 AM by Wolf-Dieter Fink

    JNDI Issue invoking remote ejb

    H R Newbie

      Hello all


      I have two computers in a LAN in my home.

      Connfigured, deployed a sample EJB 2.2 application on Jboss 6 server on a computer .


      Now, from another computer i have created a client something like this. I have placed the EJB jar on my client machine .


      package com.hello;


      import java.util.Properties;


      import javax.naming.InitialContext;

      import javax.rmi.PortableRemoteObject;



      import com.hello.home.HelloRemote;

      import com.hello.home.IHelloHome;


      public class HelloClient {



      * @param args


      public static void main(String[] args) {


         // Set up the naming provider; this may not always be

             // necessary, depending

             // on how your Java system is configured.

             Properties env = new Properties();



             env.setProperty("java.naming.provider.url",  "http://Harish_Dev:1099");

             env.setProperty("java.naming.factory.url.pkgs",  "org.jboss.naming");


             // Enclosing the whole process in a single `try'

             // block is not an ideal way

             // to do exception handling, but I don't want to clutter

             // the program up with catch blocks



                // Get a naming context

                InitialContext jndiContext = new InitialContext(env);

                System.out.println("Got context");


                // Get a reference to the Interest Bean

                Object ref  = jndiContext.lookup("HelloWorld");

                System.out.println("Got reference");


                // Get a reference from this to the Bean's Home interface

                IHelloHome home = (IHelloHome)

                PortableRemoteObject.narrow (ref, IHelloHome.class);


                // Create an Interest object from the Home interface

                HelloRemote remote = home.create();




             catch(Exception e)





      // TODO Auto-generated method stub





      I am getting the followign error when i execute the above code:

      Got context

      javax.naming.CommunicationException: Could not obtain connection to any of these urls: http://Harish_Dev:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]

      at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1690)

      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1761)

      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:695)

      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)

      at javax.naming.InitialContext.lookup(Unknown Source)

      at com.hello.HelloClient.main(HelloClient.java:39)

      Caused by: java.net.SocketTimeoutException: Receive timed out

      at java.net.TwoStacksPlainDatagramSocketImpl.receive0(Native Method)

      at java.net.TwoStacksPlainDatagramSocketImpl.receive(Unknown Source)

      at java.net.DatagramSocket.receive(Unknown Source)

      at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1659)

      ... 5 more

      [Root exception is javax.naming.CommunicationException: Failed to connect to server http://Harish_Dev:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server http://Harish_Dev:1099 [Root exception is java.net.UnknownHostException: http://Harish_Dev]]]


      any help would be greatly appreciated. thanks in advance