powered by Jive Software

Login jabbim failed via java..help me

please help me…i want to connect jabber with java…but always error:
No response from the server.:
at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication.java:74)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:404)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:349)
at com.tes.XmppManager.performLogin(XmppManager.java:64)
at com.tes.TesJabber.main(TesJabber.java:12)

package com.tes;

public class TesJabber {

	public static void main(String[] args) {
		try {
			XmppManager mager = new XmppManager("jabb.im", 0);
			mager.performLogin("wonx@jabb.im", "1234567890");
		} catch (Exception e) {


package com.tes;

import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.ChatManager;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.MessageListener;
import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Type;

public class XmppManager {
    private static final int packetReplyTimeout = 500; // millis
    private String server;
    private int port;
    private ConnectionConfiguration config;
    private XMPPConnection connection;

    private ChatManager chatManager;
    private MessageListener messageListener;
    public XmppManager(String server, int port) {
        this.server = server;
        this.port = port;
    public void init() throws XMPPException {
        System.out.println(String.format("Initializing connection to server %1$s port %2$d", server, port));

        if(port == 0){
        	 config = new ConnectionConfiguration(server);
        	 config = new ConnectionConfiguration(server, port); 	
//        config.setSASLAuthenticationEnabled(false);
//        config.setSecurityMode(SecurityMode.disabled);
        connection = new XMPPConnection(config);
        System.out.println("Connected: " + connection.isConnected());
        chatManager = connection.getChatManager();
        messageListener = new MyMessageListener();
    public void performLogin(String username, String password) throws XMPPException {
        if (connection!=null && connection.isConnected()) {
        	System.out.println("connect with user "+username);
            connection.login(username, password);

    public void setStatus(boolean available, String status) {
        Presence.Type type = available? Type.available: Type.unavailable;
        Presence presence = new Presence(type);
    public void destroy() {
        if (connection!=null && connection.isConnected()) {
    public void sendMessage(String message, String buddyJID) throws XMPPException {
        System.out.println(String.format("Sending mesage '%1$s' to user %2$s", message, buddyJID));
        Chat chat = chatManager.createChat(buddyJID, messageListener);
    public void createEntry(String user, String name) throws Exception {
        System.out.println(String.format("Creating entry for buddy '%1$s' with name %2$s", user, name));
        Roster roster = connection.getRoster();
        roster.createEntry(user, name, null);
    class MyMessageListener implements MessageListener {

        public void processMessage(Chat chat, Message message) {
            String from = message.getFrom();
            String body = message.getBody();
            System.out.println(String.format("Received message '%1$s' from %2$s", body, from));

It appears that you are using a very old version of Smack. I suggest to switch to the latest release (4.3.1, at the time of writing).

I have tried changing to the latest library (4.3.1) but it is still stuck … can you give me a simple example to connect and send a message … thank you very much