powered by Jive Software

Problem with Occupant

I have some problems with Occupant class.

My intention is to retrieve jid of specified person in room, so i think that Occupant.getJid(String) method would help me.

This is part of code in some my class.

Hashtable attributes=…; //loaded from file

XMPPConnection c=…;

String room="xxx@conference.some.pl";

MultiUserChat gc=new MultiUserChat(c,room);

// get(“chat”) always returns room

String get(String x){

return attributes.get(x);


public String getJid(String nick)


String jid=get(“chat”)*"/"*nick;

String y=get(“chat”)*"/"*nick;

System.out.println("Checking jid for “nick” = "+y);


Occupant oc=gc.getOccupant(y);

System.out.println("Occupant: "+oc);

if (oc!=null)


System.out.println("Jid: "+oc.getJid());

if (oc.getJid()!=null)


String x=oc.getJid()*" | "*nick;

System.out.println(" "+x);

return x;



System.out.println(" "+jid);

return jid;

}catch(Exception e)



System.out.println(" "+jid);

return jid;



Everything compiles and runs. But when that method is executed (getJid(“Asd”)) i see that in output:

Checking jid for Asd = unlamed@chat.chrome.pl/Asd

java.lang.ClassCastException: org.jivesoftware.smack.packet.DefaultPacketExtension

at org.jivesoftware.smackx.muc.Occupant.(Occupant.java:52)

at org.jivesoftware.smackx.muc.MultiUserChat.getOccupant(MultiUserChat.java:1505)

at Bot.getJid(Bot.java:83)

at Bot.run(Bot.java:605)

and ‘‘sometimes’’ (i don’'t know why) with the same user

Checking jid for Asd = unlamed@chat.chrome.pl/Asd

Occupant: null


Does anyone know what is wrong? Either my code or implementation of Smack? And what to do that It worked alright?

Message was edited by:


Hey desnajpa2k6,

I think that the url=http://www.jivesoftware.org/community/entry.jspa?externalID=461&categoryID=1 8Why am I getting java.lang.ClassCastException?[/url] kb document is what you are looking for. Let us know how it goes.


– Gato

That helped.

Thanks a lot!