Smack, gtalk connectivity error PLAIN: not-authorized

I am trying to connect to gmail using SMACK API but getting the below error and I am stuck with this past 2 days.

Exception in thread "main" org.jivesoftware.smack.sasl.SASLErrorException: SASLError using PLAIN: not-authorized
    at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:348)
    at org.jivesoftware.smack.tcp.XMPPTCPConnection.login(XMPPTCPConnection.java:244)
    at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:442)

I am using smack 4.0.3 jars and Java 7. gmail is not blocked in my office network. I have tired all the suggestion given in the forums.

  1. setting SASLMechanism to PLAIN / DIGEST-MD5.

  2. adding the Thread.sleep delay after connect.

  3. by setting the dummy SSLSocketFactory.

  4. removing the domain name from user name.

Below is code which I am trying to execute.

public class JabberExample {
    public static void main(String[] args) throws Exception{         XMPPTCPConnection con = new XMPPTCPConnection("gmail.com");
        SASLAuthentication.supportSASLMechanism("PLAIN",0);         con.connect();
        con.login("username", "password");         Chat chat = ChatManager.getInstanceFor(con).createChat("chatusernam@gmail.com", new MessageListener() {
             public void processMessage(Chat chat, Message message) {
                 System.out.println("Received message: " + message);
             }
         });         chat.sendMessage("Howdy!");
         // Disconnect from the server
         con.disconnect();
    }
}

I hope i get some suggestions and help here.

I met this problem also, hope someone could give a hand?