powered by Jive Software

Casting Packet Extension


I created a new PacketExtension, ie ‘‘Alias’’, and the corresponding extension provider (should I subscribe this provider somewhere?!). In testing packets are send and received, extension inclusive.

However, I can not cast the DefaultPacketExtension received from packet.getExtension(elementName, nameSpace) to my original extension ‘‘Alias’’. The xml of the extension seems to be ok, however, there is one thing a bit strange: the last and second to last xml elements changed places.

Anyone any idea how to solve my casting problem?! Tenx!




You should register your extension provider in the smack.providers file. Also make sure that the META-INF folder is present in your classpath.

Once you do that you won’'t need to cast a DefaultPacketExtension to your specific extension since Smack will locate and use your provider which in turn will answer an instance of your packet extension.

Let me know if you need more help with this.


– Gato


Thanks a lot! This solves the problem indeed.