3 Replies Latest reply on May 11, 2005 2:37 AM by elmizmo

    client cannot reconnect after server restart

    elmizmo

      Hi,

      I have a jms client program that runs as a daemon. In order to survive a jboss restart, I used the ExceptionListener. All the jndi stuff is in a helper class, which is used by the client. When an exception is encoutered, the helper notifies the client and the client closes all connections and sessions and tries to reestablish the connection after a few minutes. However, when doing this, I get this exception :

      javax.naming.CommunicationException [Root exception is java.rmi.NoSuchObjectException: no such object in table]
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:647)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at be.kmi_irm.labo.messaging.jms.JMSConnectionHelper.initConnection(JMSConnectionHelper.java:71)
      at be.kmi_irm.labo.messaging.jms.OAQ2JMSForwarder.initJMS(OAQ2JMSForwarder.java:92)
      at be.kmi_irm.labo.messaging.jms.OAQ2JMSForwarder.onJMSException(OAQ2JMSForwarder.java:154)
      at be.kmi_irm.labo.messaging.jms.JMSConnectionHelper.onException(JMSConnectionHelper.java:142)
      at org.jboss.mq.Connection.asynchFailure(Connection.java:439)
      at org.jboss.mq.il.uil2.UILClientILService.asynchFailure(UILClientILService.java:145)
      at org.jboss.mq.il.uil2.SocketManager$ReadTask.handleStop(SocketManager.java:398)
      at org.jboss.mq.il.uil2.SocketManager$ReadTask.run(SocketManager.java:332)
      at java.lang.Thread.run(Thread.java:534)
      Caused by: java.rmi.NoSuchObjectException: no such object in table
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
      ... 11 more


      Although jboss is again up , apparantly the jndi lookups fail. What could cause this ? If I restart the client everything is fine again.
      I am using jboss 4.0 .

      Thanks,

      Henk

        • 1. Re: client cannot reconnect after server restart
          elmizmo

          Ok found it !
          I looks like I had to close the Initialcontext first.
          Works nicely now.

          cya

          Henk

          • 2. Re: client cannot reconnect after server restart
            manishsingh

            would u mind sending a code snippet. I tried the closing the initial context but no success.

            • 3. Re: client cannot reconnect after server restart
              elmizmo

              Here's what I do when I encounter an exception via the onException(JMSException) method :

               if (jndiContext != null) {
               try {
               logger.debug("Closing JNDI InitialContext.");
               jndiContext.close();
               } catch (NamingException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
               }
               }
               if (session != null) {
               try {
               logger.debug("Closing JMS Session.");
               session.close();
               } catch (JMSException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
               }
               }
               if (connection != null) {
               try {
               logger.debug("Closing JMS Connection ...");
              
               connection.close();
               } catch (JMSException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
               }
               }
              


              after that, I try to reconnect after a few minutes.
              Hope this helps ?

              Henk