11 Replies Latest reply on Nov 12, 2003 1:51 PM by Joel Rosi-Schwartz

    Client reconnecting to JBoss

    dcrot Newbie

      Our stand-alone Java client application needs to reconnect to Jboss when Jboss has been brought down and restarted.

      To test this I have a simple Java client application, and Jboss with a stateless session bean that simply echo's the string sent from the client. This is using 3.2.1 on W2K Server.

      Heres the sequence of steps.
      1. Bring up Jboss
      2. Bring up client application that makes a call to the session bean which echos the string.
      3. Client blocks on a dialog.
      4. Bring down and restart Jboss.
      5. Press in dialog with the client attempting to make the same call on the session bean.

      At this point, I receive a ConnectException on the client. I then recreate the initialContext, but the client again throws a ConnectException when I'm looking up the EJB home object?

      Does anybody have any ideas on this?

      thanks,

      Dean

      PS Heres my stack trace...

      javax.naming.CommunicationException. Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.0.114; nested exception is:
      java.net.ConnectException: Connection refused: connect
      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
      at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
      at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:101)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:492)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:471)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at com.lds.client.Client.main(Client.java:31)
      Caused by: java.net.ConnectException: Connection refused: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
      at java.net.Socket.connect(Socket.java:426)
      at java.net.Socket.connect(Socket.java:376)
      at java.net.Socket.(Socket.java:291)
      at java.net.Socket.(Socket.java:119)
      at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
      at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:562)
      ... 8 more






        • 1. Re: Client reconnecting to JBoss
          Adrian Brock Master

          Your RMI object is no longer valid, the server no longer
          exists. You should reperform the lookup of the home.

          Regards,
          Adrian

          • 2. Re: Client reconnecting to JBoss
            dcrot Newbie

            Adrian,

            thats exactly what I do, as when I catch the exception due to my invalid rmi object, I recreate the initalContext and then perform the lookup for the home object again. Its during this lookup of the home object that its throws another ConnectException?

            Obviously, when I restart my stand-alone Java client application it connects fine. Any ideas?


            thanks,

            Dean

            • 3. Re: Client reconnecting to JBoss
              Adrian Brock Master

              When you "recreate the initial context" do you see it
              going back to the server on port 1099 to get the new
              stub?

              Regards,
              Adrian

              • 4. Re: Client reconnecting to JBoss
                dcrot Newbie

                Adrian,

                the ConnectException states the correct ip address that its trying to reconnect to in the exceptions stack trace, but not the port number. How can I determine if its trying to reconnect on port 1099?


                thanks,

                Dean

                • 5. Re: Client reconnecting to JBoss
                  Adrian Brock Master

                  If you don't have something to snoop on the network,
                  try enabling TRACE logging for org.jnp

                  Regards,
                  Adrian

                  • 6. Re: Client reconnecting to JBoss
                    Torsten Greiff Newbie

                    I am having the same problem. May be it's a bug in JBoss.

                    • 7. Re: Client reconnecting to JBoss
                      wodi Newbie

                      Hi

                      is there any solution for the reconnect?

                      After server restart, my client does

                      context.close()
                      context = new InitialContext()
                      srvHome = (MyServiceHome) contextt.lookup(..)

                      but this also ends in a exception rgarding TCP connection.

                      Wolfram

                      • 8. Re: Client reconnecting to JBoss
                        Darran Lofthouse Master

                        Which of your three lines of code is it that throws the exception?

                        • 9. Re: Client reconnecting to JBoss
                          wodi Newbie

                          Hi

                          the conetx.lookup(...) throws the Exception

                          javax.naming.CommunicationException. Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.1.16; nested exception is:
                          java.net.ConnectException: Connection refused
                          at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
                          at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
                          at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
                          at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:101)
                          at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
                          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:493)
                          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:472)
                          at javax.naming.InitialContext.lookup(InitialContext.java:347)
                          at tmt.bs.client.ServiceLocator.lookup(ServiceLocator.java:165)
                          at tmt.bs.client.ServiceLocator.getHome(ServiceLocator.java:284)
                          at tmt.bs.client.BillingService.getBillingServiceServer(BillingService.java:455)
                          at tmt.bs.client.BillingService.authoriseApplicationEvent(BillingService.java:196)
                          at tmt.bs.client.test.BsTransactions.callAuthorisation(BsTransactions.java:338)
                          at tmt.bs.client.test.BsTransactions.doTransaction(BsTransactions.java:92)
                          at tmt.bs.client.test.BsTestCase.doSpecifiedTest(BsTestCase.java:228)
                          at tmt.bs.client.test.BsTestCase.doTest(BsTestCase.java:48)
                          at tmt.bs.client.test.TestBillingService.main(TestBillingService.java:145)
                          Caused by: java.net.ConnectException: Connection refused
                          at java.net.PlainSocketImpl.socketConnect(Native Method)
                          at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
                          at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
                          at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
                          at java.net.Socket.connect(Socket.java:426)
                          at java.net.Socket.connect(Socket.java:376)
                          at java.net.Socket.(Socket.java:291)
                          at java.net.Socket.(Socket.java:119)
                          at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
                          at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
                          at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:562)
                          ... 16 more

                          Bye Wolfram

                          • 10. Re: Client reconnecting to JBoss
                            wodi Newbie

                            Hi

                            I found a solution, I recreate a InitialContext for each lookup:

                            1. Create a InitialContext
                            2. lookup for home interface
                            3. close InitialContext

                            Bye

                            • 11. Re: Client reconnecting to JBoss
                              Joel Rosi-Schwartz Newbie

                              I am using 3.2.1 and I am tryng to solve the same problem. I tried the solution that wodi mentioned, but strangely it does not seem to work for me. In any case it is a less than optimal solution since it adds lookup overhead to the application that requires network traffic.

                              Has any one actually solved this problem? Or determined that this is a JBoss specific or general J2EE problem?