ClassCastException when trying to get additional information on MUC Users

I am currently devloping an Smack-based XMPP client with MUC-support and i am got the following problem:

When trying to recieve the list of current Participants with MultiUserChat.getParticipants() I run into the following Exception:

java.lang.ClassCastException: org.jivesoftware.smack.util.PacketParserUtils$2 cannot be cast to org.jivesoftware.smackx.packet.MUCAdmin

at org.jivesoftware.smackx.muc.MultiUserChat.getOccupants(

at org.jivesoftware.smackx.muc.MultiUserChat.getParticipants( 12)

However using MultiUserChat.getOccupants() works - but not getOccupant(fulljid) (nearly same as above)

I could repeat this issue with several Servers with different software - so it is a client problem.

Any help would be great

It looks like your META-INF/smack.providers file is not on your classpath.

Thanks! That did it.

Could you please explain how to do that?
I have asmack-android-18-0.8.9.jar included in my project but there is only MANIFEST.MF file in META-INF folder.

In case of aSmack you simply need to run the static intializer like the README tells you to do.

Thanks for the quick answer. But I already initialize SmackAndroid on startup as follows:


Is there anything else I need to do in order to register Smack’s XMPP Providers and Extensions?


No, could you show use a full stacktrace and the relevant code?

MultiUserChat muc2 = new MultiUserChat(connection, roomName+"@"+serviceName);

DiscussionHistory history = new DiscussionHistory();


muc2.join(nickName, null, history,SmackConfiguration.getPacketReplyTimeout());

//After joining room, I try to get the room info and member list

RoomInfo info = MultiUserChat.getRoomInfo(connection, roomName + “@” + serviceName);

Log.i(TAG,“Number of occupants:” + info.getOccupantsCount());

Log.i(TAG,“Room Subject:” + info.getSubject());

Collection members = muc2.getMembers(); //LINE 442 IS HERE

for(Affiliate member:members)

Log.i(TAG,“Room member:” + member.getNick() + " - " +member.getJid());

When I run this, the resulting logcat output is as follows:

I/XMPPManager(4210): Number of occupants:2

I/XMPPManager(4210): Room Subject:

E/AndroidRuntime(4210): FATAL EXCEPTION: main

E/AndroidRuntime(4210): java.lang.ClassCastException: org.jivesoftware.smack.util.PacketParserUtils$2 cannot be cast to org.jivesoftware.smackx.packet.MUCAdmin

E/AndroidRuntime(4210): at org.jivesoftware.smackx.muc.MultiUserChat.getAffiliatesByAdmin(MultiUserChat.ja va:1750)

E/AndroidRuntime(4210): at org.jivesoftware.smackx.muc.MultiUserChat.getMembers(

E/AndroidRuntime(4210): at com.firatdulger.deneme.xmpp.muc.XMPPManager.joinRoom(

E/AndroidRuntime(4210): at com.firatdulger.deneme.xmpp.muc.MainActivity$4.onClick(

E/AndroidRuntime(4210): at$ButtonHandler.handleMessage(AlertContr

E/AndroidRuntime(4210): at android.os.Handler.dispatchMessage(

E/AndroidRuntime(4210): at android.os.Looper.loop(

E/AndroidRuntime(4210): at

E/AndroidRuntime(4210): at java.lang.reflect.Method.invokeNative(Native Method)

E/AndroidRuntime(4210): at java.lang.reflect.Method.invoke(

E/AndroidRuntime(4210): at$

E/AndroidRuntime(4210): at

E/AndroidRuntime(4210): at dalvik.system.NativeStart.main(Native Method)

Message was edited by: Fırat Dülger

The provider for the MUCAdmin packaet is not loaded. I can’t tell why from the info I have. This is usually caused by not calling SmackAndroid.init() in aSmack, which will load the provider:

// MUC Admin

    pm.addIQProvider("query","[](", new MUCAdminProvider());

Your best chance is to debug why the provider isn’t used.