Presence Type/Mode problem

Hello,

I have a weird problem with getting the type or mode of a presence object.

I’'m using JBuilder 6 and when I get to the line where I get the type or mode, it skips it and gets out of the function and out of my while block, like it encountered some error.

The problem occurs at these lines:

System.out.println(p.getType().toString());

Presence.Mode mode = roster.getPresence(user).getMode();.

user is just a string of a JID which I checked and it’'s written fine, and p is a Presence object.

I know I’'m supposed to get null but it just acts like it has some kind of a porblem getting the type/mode.

I also tried to add roster.reload(); and waited for like 5 seconds before getting the roster like it was said in previous threads here, but no luck.

What am I doing wrong?

I tried everything, if someone knows what’‘s the solution please tell me what it is, it’'s very important.

Thank you.

Message was edited by: yossi1771

It will help if you could paste the function and the block that you are referring to in your post. From the little context information that I have I guess that you are having a NPE (null pointer exception). My guess is that roster.getPresence(user) is returning null. You could debug your code to find out what’'s going on.

Regards,

– Gato

ok it was the null pointer exception indeed but now I have another problem…

when I’‘m creating a presence object with Presence.Type.UNAVAILABLE I’'m getting a message in the console:

Ctx( /RemoteJabberWebApp ): 404 R( /RemoteJabberWebApp + /classes/org/jivesoftware/smack/packet/Presence.class + null) null

as you can see I’'m using a servlet, but this message is written after this line is executed, which is another class (not the servlet class):

Presence p = new Presence(Presence.Type.UNAVAILABLE);

when I’'m creating a presence object with

Presence.Type.UNAVAILABLE I’'m getting a message in

the console:

Ctx( /RemoteJabberWebApp ): 404 R(

/RemoteJabberWebApp +

/classes/org/jivesoftware/smack/packet/Presence.class

  • null) null

Are you getting a 404 FileNotFound error? Who is printing this message? What does the first and second null mean?

as you can see I’'m using a servlet, but this message

is written after this line is executed, which is

another class (not the servlet class):

Presence p = new Presence(Presence.Type.UNAVAILABLE);

Creating a new Presence does not generate the previous error. It just generates a new instance in the VM (i.e. no presence is sent to the server). It seems to me that you are having some kind of problem with your webapp and not with Smack.

Regards,

– Gato

ok,

never mind, I solved my case with a different way, without creating a new presence object, although i have created a presence object somewhere else and it doesn’'t do this error…

Thanks for the help anyway.