processMessage does not work the second time

Hi All,

I have developed an application where I log on to the Google Chat server using the smack API. Then I open up a chat with the user using the following piece of code:

public void initialization()
{
     try
     {
          newChat = this.connection.getChatManager().createChat(<gmailuserid>, new MessageListener()
          {
               public void processMessage(Chat chat, Message message)
               {
                    System.out.println("Reading Message from XMPP Server :" + message.getType());
                    if(message.getType() == Message.Type.chat)
                    {
                        RootSbb.IMMessage = message.getBody();
                        System.out.println("Reading Message from XMPP Server, message is : " + message.getBody());
                        RootSbb.newCommandRcvdFromXMPPServer = 1;
                    }
                    else
                    {
                        RootSbb.IMMessage = "No Command";
                    }
                }
          });           newChat.sendMessage("Device is ON, You can communicate as a buddy");
          System.out.println("logged in and sent chat message");
     }
     catch (XMPPException e1)      {
          e1.printStackTrace();
     }
}

I send chat messages to the server using the following piece of code:

public void sendToChatServer(String chatMessageToXMPPServer)
{
     try      {
          newChat.sendMessage(chatMessageToXMPPServer);
     }
     catch (XMPPException e1)      {
          e1.printStackTrace();
     }
}

Everything goes OK for the first time login using smack. When the user logs off from the server, the API disconnect() is used.

The issue starts with the second logon. When the login is done again and a chat session is initiated by calling the initilization() API [illustrated above], the chat message reaches the GTalk chat window and is displayed there. This is OK.

BUT, what is typed in the GTalk chat window is not registered by the processMessage API. The message sent from the GTalk window does not come to the processMessage API. So, one side of the communication stops. Can anyone tell me why this is happening?

What is also done in the program is that this whole thing for chat is a class and when the connection is disconnected then this object is destroyed by calling finalize() and when the second time login is done then a new object is made. Could this be causing the problem? I have also tried the case where there is a single file and everything is present in the single file. So, there were no other separate classes for chats (hence no objects). But I was getting the same problem there too.

Any help would be greatly appreciated. I am new to smack, so if this is a simple problem, my forgive my ignorance.

Thanks,

Anand