2
votes

i'm using aSmack (Smack port for Android) to connect to and communicate with an XMPP server (Openfire 3.7.1). i can get multi user chat to work as far as sending messages with the MultiUserChat class. however, calling any method that lists the occupants of the room fails. relevant code:

setDefaultConnection();
if(connection!=null) {
    mMuc = new MultiUserChat(connection, "[email protected]");
    try {
        mMuc.join("chester");
        mMuc.getModerators();         //line 71
        ArrayList<Affiliate> dudes = new ArrayList<Affiliate>(mMuc.getMembers());
        Iterator<Affiliate> iter = dudes.iterator();
        while(iter.hasNext()) {
            Affiliate dude = iter.next();
            Log.w(this.getClass().getName(), dude.getNick());
        }
    } catch(XMPPException xmppe) {
        Log.w(this.getClass().getName(), "MUC error: "+xmppe.getMessage());
    }
}

logcat:

07-10 13:38:56.248: ERROR/AndroidRuntime(13003): FATAL EXCEPTION: main
    java.lang.ClassCastException: org.jivesoftware.smack.util.PacketParserUtils$2
    at org.jivesoftware.smackx.muc.MultiUserChat.getOccupants(MultiUserChat.java:1797)
    at org.jivesoftware.smackx.muc.MultiUserChat.getModerators(MultiUserChat.java:1761)
    at org.apache.android.xmpp.XMPPClient$1.onClick(XMPPClient.java:71)
    at android.view.View.performClick(View.java:2532)

is there something wrong with the library or am i doing something wrong? getOccupants() seems to work.

MultiUserChat example and javadocs:
http://www.igniterealtime.org/builds/smack/docs/latest/javadoc/
http://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions/index.html

aSmack:
http://code.google.com/p/asmack/
http://code.google.com/p/asmack/issues/detail?id=72

2
u got any solution??CoronaPintu

2 Answers

3
votes

I believe your problem is being caused by a failure for asmack to load the smack.providers file which tells asmack which classes to load. If you read the README it describes how to load the smack.providers file into asmack(Thanks Flow). You need to do this before starting any XMPP activity.

Try https://github.com/Flowdalic/asmack, as the version you are working off has not been updated in 2 years.

1
votes

Please read the README of aSmack and follow the instructions about the ProviderManager.