Search code examples
androidandroid-studioxamppopenfiremultiuserchat

XMPPError: item-not-found - cancel


I am using xampp and Openfire for group chat in android. I have attached my code below which is used to join a chat room but I was getting an error saying XMPPError: item-not-found - cancel.

Though I have tried some relevant questions none of those answers helped me out. So if anyone can help me with that then it would be great.

public void joinChatRoom(String userName, String roomName) {
    try {
        Log.d("xmpp: ", "Service Name: " + connection.getServiceName());
    } catch (Exception e) {
        e.printStackTrace();
        Log.d("xmpp: ", "service name error: "+e.getMessage());
    }
    manager = MultiUserChatManager.getInstanceFor(connection);
    multiUserChat = manager.getMultiUserChat(roomName+ "@" +CHAT_ROOM_SERVICE_NAME + CHAT_SERVER_SERVICE_NAME);
    try {
        multiUserChat.join(userName);
    } catch (SmackException.NoResponseException e) {
        e.printStackTrace();
        Log.d("xmpp: ", "Chat room join Error: " + e.getMessage());
        sendBroadCast("joinerror", e.getMessage());
    } catch (XMPPException.XMPPErrorException e) {
        e.printStackTrace();
        Log.d("xmpp: ", "Chat room join Error: " + e.getMessage());
        sendBroadCast("joinerror", e.getMessage());
    } catch (SmackException.NotConnectedException e) {
        e.printStackTrace();
        Log.d("xmpp: ", "Chat room join Error: " + e.getMessage());
        sendBroadCast("joinerror", e.getMessage());
    }

    // if user joined successfully
    if (multiUserChat.isJoined()) {
        Log.d("xmpp: ", "user has Joined in the chat room");
        sendBroadCast("join", "done");
        //call method to configure room
        configRoom(roomName);

        // get Roster
        getBuddies();
        //get user info
        getUserInfo(userName);

     }
}

Solution

  • I found the answer. I just updated my Chat object. The imported class was wrong previously. Now it's corrected with the following line.

    org.jivesoftware.smack.chat.Chat