Can't login right after a createAccount without using a different connection?

I noticed if my jabber server (jabberd2) has account registration enabled, then in Smack if I try to create a new account and then immediately using that account to login, the login fails with an exception complaining Smack fails to receive the response to it final resource bind request (the SASL plain text authentication does succeed and at server side the bind also happens, it’s just somehow Smack didn’t get the bind success response from server). As a workaround, I tried to disconnect the XMPP connection after createAccount, then reconnect before the login, and that worked. I wonder why this happens?

Code:

XMPPConnection xcon = new XMPPConnection(“chat.gaocan.com”);

xcon.connect();

String acct = “test_” + new Random().nextInt(1000000);

String passwd = “test_pwd”;

xcon.getAccountManager().createAccount(acct, passwd);

// following 3 lines are a must otherwise login will fail

xcon.disconnect();

xcon = new XMPPConnection(“chat.gaocan.com”);

xcon.connect();

xcon.login(acct, passwd);

Here is the exact exception:

Exception in thread “main” No response from the server.:

at org.jivesoftware.smack.SASLAuthentication.bindResourceAndEstablishSession(SASLAuthentication.java:307)

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:214)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:341)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:301)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:283)

at com.gaocan.im.NewAccountTest.main(NewAccountTest.java:29)