3 Replies Latest reply: Mar 26, 2010 5:22 AM by nicolas duminil RSS

    Unable to use jndi.properties in standalone EJB client

    nicolas duminil Novice

      Greetings,

       

      In a stand-alone EJB client I have the following code:

       

          Hashtable env = new Hashtable();
          env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
          env.put(Context.PROVIDER_URL, "localhost:1099");
          env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
          Context ctx = new InitialContext(env);

       

      This code works properly. Now, I'm trying to use the following jndi.properties file after having commented the sequence above:

       

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

      This time I have the following exception:


      javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
              at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1678)
              at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1795)
              at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:693)
              at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
              at javax.naming.InitialContext.lookup(InitialContext.java:392)
              at fr.logica.cpv.client.TestModel.testUnmarshall(TestModel.java:40)
      Caused by: java.net.SocketTimeoutException: Receive timed out
              at java.net.PlainDatagramSocketImpl.receive0(Native Method)
              at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:136)
              at java.net.DatagramSocket.receive(DatagramSocket.java:712)
              at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1647)
              ... 31 more

      The jndi.properties file is, of course, on the execution classpath. What may the problem be ?

       

      Many thanks in adavance,

       

      Nicolas