powered by Jive Software

Java error related to Smack PubSub Listener: incompatible types

I was working on the pubsub listener for Smack and I’m getting a compilation error related to type incompatible types:
“e.getItems” returns a collection of objects, while we should be working on collection of PayloadItem. how do you do cast in this case? or is there something else I did wrong?
Here is the snipper related to the error:

Imports:
import org.jivesoftware.smack.;
import org.jivesoftware.smackx.pubsub.
;
import org.jivesoftware.smackx.pubsub.listener.;
import org.jivesoftware.smackx.pubsub.SimplePayload.
;
import org.jivesoftware.smackx.pubsub.ItemPublishEvent;
import org.jivesoftware.smackx.pubsub.SimplePayload;

Code:

eventNode.addItemEventListener(new ItemEventListener()
{
@Override
public void handlePublishedItems(ItemPublishEvent e) {
for (PayloadItem item : e.getItems()) {
System.out.println(item.getPayload().toXML());
}
}
}
);

Error:

incompatible types
found : java.lang.Object
required: org.jivesoftware.smackx.pubsub.PayloadItem<org.jivesoftware.smackx.pubsub.Simpl ePayload>
for (PayloadItem item : e.getItems()) {


I’m using the latest Java sdk/ netbeans ide. and latest smack with smackx pubsub library.