6 Replies Latest reply on Mar 5, 2004 9:18 AM by pdg

    javax.naming.CommunicationException: Receive timed out.

    tdang

      Hi all!

      I have only one machine that has a network adapter with an ip address. This machine is a standalone machine and is not on network. I installed Jboss 3.0 final on this machine and could succesfully deploy my database source and my bean, but while running the client I got the following error:

      javax.naming.CommunicationException: Receive timed out. Root exception is java.io.InterruptedIOException: Receive timed out at java.net.PlainDatagramSocketImpl.receive(Native Method) at java.net.DatagramSocket.receive(DatagramSocket.java:392) at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:919) at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:997) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:436) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:429) at javax.naming.InitialContext.lookup(InitialContext.java:350) at de.tranboutique.sales.tests.Test.main(Test.java:27)

      I suppose since this machine is a standalone machine and not on network, my client cannot communicate with JBoss. On this machine there are also others applications servers and I do not have this problem with them.

      How can I solve the problem?

      Regards.

        • 1. Re: javax.naming.CommunicationException: Receive timed out.
          tgminc

          Did you ever figure this problem out?

          I have the same issue and can seem to get past it!

          Tom

          • 2. Re: javax.naming.CommunicationException: Receive timed out.
            mahelak

            Hi,

            I figured this out - at least my installation which JBoss 3.x

            the following lines of code is required..

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

            • 3. Re: javax.naming.CommunicationException: Receive timed out.
              tdang

              I really do not know if it is really the solution for this problem because my client contains lines similar to yours, and it works on another machine in a network environment:

              Properties p = new Properties();

              p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
              p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
              p.put(Context.PROVIDER_URL, "jnp://localhost:1099");

              InitialContext context = new InitialContext(p);

              • 4. Re: javax.naming.CommunicationException: Receive timed out.
                tdang

                I really do not know if it is really the solution for this problem because my client contains lines similar to yours, and it works on another machine in a network environment:

                Properties p = new Properties();

                p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                p.put(Context.PROVIDER_URL, "jnp://localhost:1099");

                InitialContext context = new InitialContext(p);

                • 5. Re: javax.naming.CommunicationException: Receive timed out.
                  rsuffling

                  Sounds like you have a socket timeout. Here are the JNDI properties I've been using. The last two settings deal with socket timeout so it might be worth tryiing it out.

                  jndi properties

                  java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                  java.naming.provider.url=localhost:1099/
                  java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
                  # The jnp protocol socket factory class
                  jnp.socketFactory=org.jnp.interfaces.TimedSocketFactory
                  # The TimedSocketFactory connection timeout in milliseconds(0 == blocking)
                  jnp.timeout=0
                  # The TimedSocketFactory read timeout in milliseconds(0 == blocking)
                  jnp.sotimeout=0

                  • 6. Re: javax.naming.CommunicationException: Receive timed out.
                    pdg

                    Hi,

                    I thought this was the solution, but it isn't... :-(

                    The strange thing is, it happens only when i have a quite high load.. this is the situation.

                    I have JBoss instances in one partition (Default partition)

                    On these instances, I deployed a Stateful SessionBean.

                    When call some methods on it, it seems to work.
                    When I start 30 threads that call the same methods, some of them get the following exception(s) during creation of the InitialContext.
                    (Maybe good to know, It happens in both cases: when both servers are running AND when only one server runs)

                    This is how I create my InitialContext:

                    Properties p = new Properties();
                    p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
                    p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
                    p.put(Context.PROVIDER_URL, "10.0.0.57, 10.0.0.65");
                    // The TimedSocketFactory connection timeout in milliseconds(0 == blocking)
                    p.put("jnp.socketFactory","org.jnp.interfaces.TimedSocketFactory");
                    p.put("jnp.timeout","0");
                    // The TimedSocketFactory read timeout in milliseconds(0 == blocking)
                    p.put("jnp.sotimeout","0");

                    The Exceptions I get:

                    javax.naming.CommunicationException: Receive timed out. Root exception is java.io.InterruptedIOException: Receive timed out
                    at java.net.PlainDatagramSocketImpl.receive(Native Method)
                    at java.net.DatagramSocket.receive(DatagramSocket.java:387)

                    OR

                    javax.naming.CommunicationException: Failed to retrieve stub from server 0.0.0.0:110. Root exception is java.io.StreamCorruptedException: Caught EOFException while reading the stream header
                    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:840)
                    at java.io.ObjectInputStream.(ObjectInputStream.java:163)
                    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:197)
                    at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1107)
                    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1192)
                    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:514)
                    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
                    at javax.naming.InitialContext.lookup(InitialContext.java:345)
                    at com.vangenechten.multitier.ShoppingCartTest.lookupHome(ShoppingCartTest.java:146)
                    at com.vangenechten.multitier.ShoppingCartTest.testAddItems(ShoppingCartTest.java:51)
                    at com.vangenechten.multitier.ShoppingCartTest$1.run(ShoppingCartTest.java:101)
                    at java.lang.Thread.run(Thread.java:479)