powered by Jive Software

Getting java object out of Element in Openfire Plugin

Hi All,

I am sending a java object by setting it as a property in the org.jivesoftware.smack.packet.Message object. Message is recieved by my plugin application at the openfire. I have registered my plugin as a Component. Now, when I try to extract this object with org.dom4j.Element’s getData and typecast it with my Java Object’s class, I get a type cast error. This method is returning a String object which of course will give me the typecast error.

I request you to help me with this one as sending a java object (java bean) between openfire and my Smack client is very important for my application. If my approach for doing this is not right, then please guide me on how I can acheive this.

Code Snippet:

Client side:

Message mess = new Message();

mess.setProperty(“testProperty”, object); // object is a serializable object

mess.setBody(“Message with Object”);


Server Side:

org.dom4j.Element element = packet.getElement();

org.dom4j.Element el = null;

el = element.element(“properties”);

if (el != null)

el = el.element(“property”);

if (el != null)

el = el.element(“value”);

if (el != null)

DataObject obj = (DataObject)el.getData();

Best Regards,


Hi Nitin,

XMPP doesn’t like binary data :). I suggest that you convert binary objects to Base64 first before sending it in an XMPP packet.

Thanks Aznidin. It worked.

Best Regards,

Nitin Gupta

Srishti TechNet Pvt. Ltd.

B1/168, Paschim Vihar,

New Delhi - 110063