Problem getting the correct Presence from the Roster

I am trying to write a servlet which logs a user on within the servlet (using the default resource) and then performs an action for all buddies which are currently also logged on. However, if I run the following code, the only presence I get is “unavailable”. I know this is not true, as the openfire admin portal verifies that some of the user’s buddies are online and available.

XMPPConnection userConn = new XMPPConnection(“”);
userConn.login(sender, password);

Roster roster = userConn.getRoster();
Collection entries = roster.getEntries();

for(RosterEntry r:entries)


Can someone else explain this please?

Is there a race condition where I am going trying to get the presence of buddies before the roster has received the presence info? If so, what would be the best way to solve it?