5 Replies Latest reply on Oct 3, 2010 7:06 PM by Peter Johnson

    Failed to connect to server 10.0.1.170:1099

    charlie cha Newbie

      I have this error message when I run Jbuilder & Jboss 4 on the lookup();
      Please help me out to make this work !!

      this is the code for environment

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


      this is the error message
      javax.naming.CommunicationException: Failed to connect to server 10.0.1.170:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 10.0.1.170:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
       at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:269)
       at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at test2.HelloTestClient.initialize(HelloTestClient.java:25)
       at test2.HelloTestClient.<init>(HelloTestClient.java:15)
       at test2.HelloTestClient.main(HelloTestClient.java:93)
      Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server 10.0.1.170:1099 [Root exception is java.net.ConnectException: Connection refused: connect]
       at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:243)
       ... 7 more
      Caused by: java.net.ConnectException: Connection refused: connect
       at java.net.PlainSocketImpl.socketConnect(Native Method)
       at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
       at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
       at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
       at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
       at java.net.Socket.connect(Socket.java:507)
       at java.net.Socket.connect(Socket.java:457)
       at java.net.Socket.<init>(Socket.java:365)
       at java.net.Socket.<init>(Socket.java:265)
       at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
       at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
       at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:239)
       ... 7 more
      javax.naming.CommunicationException: Could not obtain connection to any of these urls: 10.0.1.170:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server 10.0.1.170:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 10.0.1.170:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]]
       at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1414)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at test2.HelloTestClient.initialize(HelloTestClient.java:25)
       at test2.HelloTestClient.<init>(HelloTestClient.java:15)
       at test2.HelloTestClient.main(HelloTestClient.java:93)
      Caused by: javax.naming.CommunicationException: Failed to connect to server 10.0.1.170:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 10.0.1.170:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
       at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:269)
       at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385)
       ... 6 more
      Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server 10.0.1.170:1099 [Root exception is java.net.ConnectException: Connection refused: connect]
       at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:243)
       ... 7 more
      Caused by: java.net.ConnectException: Connection refused: connect
       at java.net.PlainSocketImpl.socketConnect(Native Method)
       at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
       at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
       at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
       at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
       at java.net.Socket.connect(Socket.java:507)
       at java.net.Socket.connect(Socket.java:457)
       at java.net.Socket.<init>(Socket.java:365)
       at java.net.Socket.<init>(Socket.java:265)
       at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
       at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
       at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:239)
       ... 7 more
      


        • 1. Re: Failed to connect to server 10.0.1.170:1099
          Peter Johnson Master

          The error message states that port 1099 is not open on server 10.0.1.170. You can use the netstat command to see what ports are open. If the port is open, then check your firewall settings. Also, try to telnet to the port: "telnet 10.0.1.170 1099"

          • 2. Re: Failed to connect to server 10.0.1.170:1099
            charlie cha Newbie

            the port 1099 was working so that I changed the port to 1199 which is open as below:

            C:\Documents and Settings\charliecha.THG_NEW>telnet localhost 1199
            Connecting To localhost...Could not open a connection to host on port 1199 : Con
            nect failed


            But same result
            DEBUG org.jnp.interfaces.NamingContext - Failed to connect to 10.0.1.170:1199
            javax.naming.CommunicationException: Failed to connect to server 10.0.1.170:1199 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 10.0.1.170:1199 [Root exception is java.net.ConnectException: Connection refused: connect]]
             at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:269)
             at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
             at javax.naming.InitialContext.lookup(InitialContext.java:351)
             at test2.HelloTestClient.initialize(HelloTestClient.java:25)
             at test2.HelloTestClient.<init>(HelloTestClient.java:15)
             at test2.HelloTestClient.main(HelloTestClient.java:93)
            Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server 10.0.1.170:1199 [Root exception is java.net.ConnectException: Connection refused: connect]
             at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:243)
             ... 7 more
            Caused by: java.net.ConnectException: Connection refused: connect
             at java.net.PlainSocketImpl.socketConnect(Native Method)
             at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
             at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
             at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
             at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
             at java.net.Socket.connect(Socket.java:507)
             at java.net.Socket.connect(Socket.java:457)
             at java.net.Socket.<init>(Socket.java:365)
             at java.net.Socket.<init>(Socket.java:265)
             at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
             at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
             at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:239)
             ... 7 more
            


            • 3. Re: Failed to connect to server 10.0.1.170:1099
              Peter Johnson Master

              According to the telnet output, port 1199 is not open. Try entering the command "netstat -ab", look at the results to see what ports has open. Or, download and run tcpview from http://www.sysinternals.com/Utilities/TcpView.html, it's easier to use and runs faster than netstat.

              • 4. Re: Failed to connect to server 10.0.1.170:1099
                Roland Thomas Lichti Newbie

                Peter Johnson schrieb:

                 

                According to the telnet output, port 1199 is not open. Try entering the command "netstat -ab", look at the results to see what ports has open. Or, download and run tcpview from http://www.sysinternals.com/Utilities/TcpView.html, it's easier to use and runs faster than netstat.

                I have the problem, that the port is open:

                 

                {code}klenkes@manitu:/opt/jbossesb-4.9/samples/quickstarts/helloworld$ netstat -tnl
                Aktive Internetverbindungen (Nur Server)
                Proto Recv-Q Send-Q Local Address           Foreign Address         State    

                ...
                tcp        0      0 10.1.2.133:1099         0.0.0.0:*               LISTEN 

                ...

                {code}

                 

                But when trying to send a message the JNDI is not found:

                 

                {code}

                runtest:
                     [echo] Runs Test JMS Sender
                     [java] Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: 10.1.2.133 and discovery failed with error: javax.naming.CommunicationException: Network is unreachable [Root exception is java.io.IOException: Network is unreachable] [Root exception is javax.naming.CommunicationException: Failed to connect to server /10.1.2.133:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server /10.1.2.133:1099 [Root exception is java.net.SocketException: Network is unreachable]]]
                     [java]     at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1763)
                     [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:693)
                     [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
                     [java]     at javax.naming.InitialContext.lookup(InitialContext.java:392)
                     [java]     at org.jboss.soa.esb.samples.quickstart.helloworld.test.SendJMSMessage.setupConnection(SendJMSMessage.java:53)
                     [java]     at org.jboss.soa.esb.samples.quickstart.helloworld.test.SendJMSMessage.main(SendJMSMessage.java:82)
                     [java] Caused by: javax.naming.CommunicationException: Failed to connect to server /10.1.2.133:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server /10.1.2.133:1099 [Root exception is java.net.SocketException: Network is unreachable]]
                     [java]     at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:335)
                     [java]     at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1734)
                     [java]     ... 5 more
                     [java] Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server /10.1.2.133:1099 [Root exception is java.net.SocketException: Network is unreachable]
                     [java]     at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:305)
                     [java]     ... 6 more
                     [java] Caused by: java.net.SocketException: Network is unreachable
                     [java]     at java.net.PlainSocketImpl.socketConnect(Native Method)
                     [java]     at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
                     [java]     at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
                     [java]     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
                     [java]     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
                     [java]     at java.net.Socket.connect(Socket.java:529)
                     [java]     at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:97)
                     [java]     at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:82)
                     [java]     at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:301)
                     [java]     ... 6 more

                 

                {code}

                 

                Thats the definition of the initial context (I changed the IP in the esb sample helloworld):

                 

                {code}

                Properties properties1 = new Properties();
                                properties1.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                                properties1.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                                properties1.put(Context.PROVIDER_URL, "jnp://10.1.2.133:1099");

                 

                                InitialContext iniCtx = new InitialContext(properties1);

                 

                {code}

                • 5. Re: Failed to connect to server 10.0.1.170:1099
                  Peter Johnson Master

                  I suspect that your /etc/hosts file is not properly configured. See if this discussion helps: http://community.jboss.org/thread/120995