ClassCastException when using MUC

Hi,

I am getting a ClassCastException when using MUC and try to get the participants of a room or create a room.

I am using jabberd 1.4 with MUC on Debian. That is pretty much the default, isn’'t it? Regarding smack I am using a daily build from mid july.

I get a ClassCastException in org.jivesoftware.smackx.muc.MultiUserChat.getMUCUserExtension, line 1629, called from the READER thread.

A code sample is here: http://tinyurl.com/6mr8h

Anything I am doing wrong here?

Cheers,

Mariano

Mariano,

Check that the smack.providers file is in you classpath. It seems that Smack can’'t locate that file so you are getting a DefaultPacketExtension instead of a MUCUser.

Regards,

– Gato

Hey Gato,

thanks. That was it.

I am using smack inside eclipse and build from the sources, but without ant. I double-checked the build.xml file now. That was the only thing to be done, but to compile the classes then, right?

I am facing a follow-up problem now when trying to create a room. I get the following exception:

Creation failed - Missing acknowledge of room creation.:

at org.jivesoftware.smackx.muc.MultiUserChat.create(MultiUserChat.java:293)

at test.smack.ChatTest.main(ChatTest.java:23)

Exception in thread “main”

And it happens here:


// Look for confirmation of room creation from the server

MUCUser mucUser = getMUCUserExtension(presence);

if (mucUser != null && mucUser.getStatus() != null) {

if ("201".equals(mucUser.getStatus().getCode())) {

// Room was created and the user has joined the room

return;

}

}

// We need to leave the room since it seems that the room already existed

leave();

throw new XMPPException("Creation failed - Missing acknowledge of room creation.");

if (mucUser != null && mucUser.getStatus() != null) {

mucUser.getStatus() returns null.

Here is my breaking code:

http://tinyurl.com/5szo5 (http://www.jabberstudio.org/cgi-bin/viewcvs.cgi/pepemax/pepe

max/Scratchpad/src/test/smack/ChatTest.java?view=markup)

Against what server are you running your code?

Mariano

Sorry, my fault. It seems I need to use the same name for creating the MultiUserChat as for the room creation. Makes sense.

Anyway, why am I able to specify the name during create() then?

Cheers,

Mariano

Mariano,

The name that you specify during #create() is your nickname in the room. Take in consideration that when you create a new room you immediately join the new room with the specified nickname.

– Gato

Ok, understood.