3

I am using aSmack for creating chat application. When i am creating groupchat by using this aSmack it gives error. this is the code am using for creating GroupChat.

MultiUserChat muc = new MultiUserChat(connection, "xyz@abc.com");           

try {
    muc.create(u_name);              
    Form form = muc.getConfigurationForm();              
    Form submitForm = form.createAnswerForm();               
    for (Iterator<FormField> fields = form.getFields(); fields.hasNext();) {
        FormField field = (FormField) fields.next();
        if (!FormField.TYPE_HIDDEN.equals(field.getType()) && field.getVariable() != null) {                 
            submitForm.setDefaultAnswer(field.getVariable());
        }
    }
    List<String> owners = new ArrayList<String>();
    Log.i(TAG, "list of owners=====" +owners.toString());
    owners.add(PmUser_name);
    submitForm.setAnswer("muc#roomconfig_roomowners", owners);               
    muc.sendConfigurationForm(submitForm);
} catch (XMPPException e) {          
    e.printStackTrace();
}

This is the jar i am using for aSmack asmack-2010.05.07.jar. it supports facebook xmpp, Gtalk xmpp and my own server xmpp chat. Now i want to create group chat for my own server, but it give this error.

E/AndroidRuntime(31002): Caused by: java.lang.ClassCastException:   
org.jivesoftware.smack.packet.DefaultPacketExtension
E/AndroidRuntime(31002):    at  
org.jivesoftware.smackx.muc.MultiUserChat.getMUCUserExtension(MultiUserChat.java:2000)
E/AndroidRuntime(31002):    at    
org.jivesoftware.smackx.muc.MultiUserChat.create(MultiUserChat.java:364)

I have search a lot but still didn't get any idea about how to solve this.

Any help would be appreciated before I pull my hair out.

Flow
  • 23,572
  • 15
  • 99
  • 156
RajaReddy PolamReddy
  • 22,428
  • 19
  • 115
  • 166

1 Answers1

4

The Packet Providers of Smack where not registered. You get a ClassCastException because Smack is unable to create the correct Packet class instance for MUC. I suggest that you use a newer version of aSmack and follow the instructions in the README, which should initialize and register the Providers for you.

Flow
  • 23,572
  • 15
  • 99
  • 156
  • now i am able to create room, but that is unable to see in list of available HostedRomms for a that domain. what i have to do for that. – RajaReddy PolamReddy Apr 04 '13 at 11:01
  • It would be polite if you would first upvote the answer that helped you to solve the problem and mark it accepted. Also please don't ask different questions here, instead, create a new question. – Flow Apr 04 '13 at 11:17
  • Sorry Flow, i was accepted and upvoted your answer it helped for me, guide how to solve my problem now or provide any link i will try to solve that.please. – RajaReddy PolamReddy Apr 04 '13 at 11:19
  • hai, can you help me on this MultiUserChat. i am unable to understand how to follow to solve this.http://stackoverflow.com/questions/15831855/how-to-get-discussionhistory-for-multiuserchat-room-using-asmack – RajaReddy PolamReddy Apr 05 '13 at 11:26