powered by Jive Software

OfflineMessageManager issue trying to retrieve offline messages

I would like to know how many offline messages are pending. I am using Smack 2.1/Jive 2.2.2.

So I tried:

XMPPConnection tempConn = new XMPPConnection(host);

tempConn.login(user, PASSWORD);

OfflineMessageManager oMgr = new OfflineMessageManager( tempConn );

if( oMgr.supportsFlexibleRetrieval())

return oMgr.getMessageCount();

It dies of NullPointerException in supportFlexibleRetrieval OfflineMessageManager.java:80 ServiceDiscoveryManager.getInstanceFor(connection) is null.

Is this the right way to use the OfflineManager? Any reason why there is no ServiceDiscoverManager being returned?

Thanks.

Pat.

Hey Pat,

You don’'t have to send an available presence when logging in. Otherwise, the server will send offline messages to the client and offline messages will be removed from the database. You should have to use the #login method that allows you to specify that an available presence should not be sent.

You can also take a look at the OfflineMessageManagerTest class to see a working example of this feature.

Regards,

– Gato

Gato,

Thanks. I tried to run the test case with Smack 2.1 (and 2.0) and get the same error:

java.lang.ClassCastException: org.jivesoftware.smack.PacketReader$4

at org.jivesoftware.smackx.ServiceDiscoveryManager.discoverInfo(ServiceDiscoveryMa nager.java:362)

We tried on 2 different machines (Mac and PC running Java 1.5 against Server 2.2.2)

Thanks.

Pat.

Hey Pat,

The following KB document (http://www.jivesoftware.org/community/entry.jspa?externalID=461&categoryID=18) might help you. It seems that the META-INF/smack.providers file is missing in your classpath or is an old version.

Regards,

– Gato

Gato,

I bow to the Master.

Thanks.

Pat.