powered by Jive Software

Ways to Delete Entry from roster

What are the ways of removing the entry from the roster ??

There are 2 ways I know

RosterEntry contact = r.getEntry(contact);


RosterPacket rpac = new RosterPacket();

RosterPacket.Item iii = new RosterPacket.Item(cont*"@"*host, cont);






The problems with these two methods are that after removing the entry from roster, it gets disconnected???

What is it so ? ? ?

Is there any way other that the above…




What Smack version are you using?

To remove entries from the roster you should use Roster.removeEntry(RosterEntry entry). This is the only public way to do it. The Roster class will take care of removing the entry using a RosterPacket. You don’'t have to directly use a RosterPacket.

The problems with these two methods are that after

removing the entry from roster, it gets


Do you know who is closing the connection? Is it Smack or the server? BTW, what server are you using? Can you post the answer of the server after sending the entry removal order?


– Gato

First of all let me tell you that the connection is closed by the smack…

The server which i am using is jabberd & I am using the latest smack api 1.2.1-----It seems that closing stream is send from some where ? ?

and secondly I have also enabled the debug mode but the window never appears.

Remove entry from roster works fine for the first time and gets disconnected and when I try to perform other operation The only exception i get is

java.lang.IllegalStateException: Not connected to server

Simply because it is not connected

Point is when i try to perform some other operation like add or delete.


Smack will close the connection under two circumstances.

  1. An exception while parsing the received packet from the server

  2. A closing stream is sent from the server

We need to open a debugger to see the XML that Smack is receiving to detect which is your case. In my opinion your case is the first one but we have to analyze the offending XML.

From your post I see that you are also having problems opening the debugger. There are two ways to open a debugger:

  1. Add the following line of code before creating new connections
XMPPConnection.DEBUG_ENABLED = true;
  1. Start the Java application setting the system property smack.debugEnabled to true (e.g. java -Dsmack.debugEnabled=true SomeApp)

Once you have opened the debugger please post the XML stanzas.


– Gato

Ok thanks for the assiastance.

The xml send to the server is

The xml received from the server is

<iq xmlns=’‘jabber:client’’ id=’‘77WP2-39’’ type=’‘result’’/>

<presence xmlns=’‘jabber:client’’ from=’‘amina@aquarious.imaxan.ie’’ to=’‘sohail3@aquarious.imaxan.ie/Smack’’ type=’‘error’’>

<error type=’‘cancel’’ code=’‘404’’>

<item-not-found xmlns=’‘urn:ietfaramsml:nsmpp-stanzas’’/>

After analyzizing I can easily conclude what was the problem…

Ok let me summarize it

First of all I had been adding contacts in the roster that were never registered in the server. In other words dummy entries…

And finally when i tried to remove those dummy entries, at first I could remove it but it get disconnected i.e stream is closed

Now tell me that while adding new entries in the roster, how can we make a check that it not a dummy entry i.e the user is registered in jabberd Server…

I think you got my point ! !

With Best Regards,

Sohail Qureshi


The reason why you are being disconnected is that Smack 1.2.1 cannot parse the error returned from the server because of the error format (raise an exception!). Please, download a daily build version and try again.

– Gato