powered by Jive Software

roster.getPresence issue

Hi everyone,

I’'m currently working on MyOwnMessenger again. The thing is that I want to know what presence everyone in my roster has.

But it is somewhat confusing. What does roster.getPresence require for param? It says a String user. But is that the JID?

Then I’'ve got a problem.

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


Gives a nullpointer problem. entry is a RosterEntry, and the user really exists.

Am I doing something wrong?


Mark Monster

Hey Mark,

You have to send something like "user@serverhost.com" to roster.getPresence as a parameter. The method comment specifies that user param is “a fully qualified xmpp ID, e.g. jdoe@example.com”. If the user is not found in the roster then you will receive a null value otherwise you will get the user’'s presence.

When you say that you are getting a “a nullpointer problem.”, what do you mean? Are you getting an exception or a null value? If it is an exception then a stack trace could help.


– Gato

Message was edited by: dombiak_gaston

It is a null value really. But that’'s very strange, I first get those JID from the Roster and a moment later he has forgotten that it was in the roster?


Mark Monster

PS. Excuse me for the confusing about nullpointer problem.

I see the problem. When the user is on the roster, but not online. It will also give a null value.

Thanks anyway,


Mark Monster


You are right. We will modify the method comment to clarify this situation.


– Gato