Roster.getEntries returning 0

I am creating a java fx application for openfire chat client. i am using smack 4.1 rc1 to connect to the server. i am able to to connect to server send presence information to others and send messages to other users as well. however i am not able to iterate through the roster.

when i get roster object and debug it its shows a hash map of 3 roster entries that means the roster is getting loaded in roster object. however when i use roster.getentries method to store it into the Collection of roster entries it shows 0 object. even the roster.getentriescount() method returns 0 though i can see the roster user names in the debug view

       Roster roster = Roster.getInstanceFor(conn); Collection<RosterEntry> entries = roster.getEntries();  int i=0; for (RosterEntry entry : entries) { System.out.println(entry); i++; } System.out.println("Rosters Count - "+ i+ roster.getEntryCount());

has any one encountered the same problem before?

We might need to see more of your code to determine the problem. Have you also tried seeing the output of entries.size()?

Hi John ,

Im facing the same problem can you help me with this .

I can send and receive messages.

But cant get any details of other users ?

Roster roster = connection.getRoster();

int count = roster.getEntryCount();

System.out.println(count);

Collection entries = roster.getEntries();

for (RosterEntry entry : entries) {

Log.i(“Chats”, “--------------------------------------”);

Log.d(“Chats”, "RosterEntry " + entry);

Log.i(“Chats”, "User: " + entry.getUser());

Log.i(“Chats”, "Name: " + entry.getName());

Log.i(“Chats”, "Status: " + entry.getStatus());

Log.i(“Chats”, "Type: " + entry.getType());

Presence entryPresence = roster.getPresence(entry.getUser());

Log.d(“Chats”, "Presence Status: "+ entryPresence.getStatus());

Log.d(“Chats”, "Presence Type: " + entryPresence.getType());

Presence.Type type = entryPresence.getType();

if (type == Presence.Type.available)

Log.d(“Chats”, “Presence AVIALABLE”);

Log.d(“Chats”, "Presence : " + entryPresence);

}

}