Login to gtalk via smack only works after login to google account via web?

Hi all,

I have a small question… I am writing a tool which is making use of smack in conjunction with gtalk and Google App Engine.

When I want to login to gtalk with smack (this is in a unit test), this initially fails. However, when I first login to google with the same account as in the unit test via a browser, and then rerun the unit test, all is well.

Has anybody seen this behaviour? The code is as follows (and I’m sure my username and password are ok):

public void initialize() throws LifeCycleException {
          XMPPConnection.DEBUG_ENABLED = true;
          ConnectionConfiguration connConfig = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
          connConfig.setSASLAuthenticationEnabled(false);
          try {
                   initializeXMPPConnection(new XMPPConnection(connConfig));
          } catch (XMPPException xmmpException1) {
                   connConfig = new ConnectionConfiguration("talk.google.com", 5222, "googlemail.com");
                    connConfig.setSASLAuthenticationEnabled(false);
                    try {
                     initializeXMPPConnection(new XMPPConnection(connConfig));
                    } catch (XMPPException xmmpException2) {
                         throw new LifeCycleException("Could not initialize", xmmpException2);
                    }
          }
} protected void initializeXMPPConnection(XMPPConnection xmppConnection) throws XMPPException {
          this.xmppConnection = xmppConnection;
          this.xmppConnection.connect();
          this.xmppConnection.login(userName, password, resourceName);
          PacketFilter packetFilter = new MessageTypeFilter(Message.Type.chat);
          xmppConnection.addPacketListener(this, packetFilter);
}

It always fails on the line where the login happens. The stacktrace is as follows:

Caused by: forbidden(403) Username or password not correct.
          at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication.java:110)
          at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:404)
          at be.rosoco.jmom.remote.RemoteIntentManagerImpl.initializeXMPPConnection(RemoteIntentManagerImpl.java:67)
          at be.rosoco.jmom.remote.RemoteIntentManagerImpl.initialize(RemoteIntentManagerImpl.java:57)
          ... 25 more

Thanks in advance,

Ronald