Smack error in pubsub subscribe response

Hi, this is my first post here and my english is not very good, so sorry for that
I’m working with a pubsub node, which is in authorize mode.
i make a StanzaListener on the owner of the node to authorize the subscription of users:

(i think the next code is ok, but i put it because i think it can help to understand and i dont know if this is the best way to do it)

StanzaListener myListener = new StanzaListener() {
            public void processPacket(Stanza packet) {
               for(ExtensionElement extension : packet.getExtensions())
                    switch (extension.getNamespace())
                         case "jabber:x:data":
                            Form form=Form.getFormFrom(packet);
                            if (form.getField("FORM_TYPE").getValues().get(0).equals(""))
                                Form answer = form.createAnswerForm();
                                for (FormField field : answer.getFields())
                                        case "pubsub#allow":
                                            //I know, i accept all users for know
                                        case "FORM_TYPE":
                                Message respuesta = new Message(packet.getFrom());
                                try {
                                } catch (SmackException.NotConnectedException ex) {
                                    Logger.getLogger(Xmpp.class.getName()).log(Level.SEVERE, null, ex);

The problem is that when a user try to subscribe to the node, with this code:

LeafNode node = pubsubManager.getNode("thePubsubNode");
node.addItemEventListener(new ItemPubsubListener());

it gets this message error in the console:

Connection closed with error

java.lang.ClassCastException: org.jivesoftware.smack.packet.DefaultExtensionElement cannot be cast to org.jivesoftware.smackx.pubsub.NodeExtension

at org.jivesoftware.smackx.pubsub.provider.EventProvider.createReturnExtension(Eve

at org.jivesoftware.smackx.pubsub.provider.EventProvider.createReturnExtension(Eve

at org.jivesoftware.smack.provider.EmbeddedExtensionProvider.parse(EmbeddedExtensi

at org.jivesoftware.smack.provider.EmbeddedExtensionProvider.parse(EmbeddedExtensi

at org.jivesoftware.smack.provider.Provider.parse(

at org.jivesoftware.smack.util.PacketParserUtils.parseExtensionElement(PacketParse

at org.jivesoftware.smack.util.PacketParserUtils.addExtensionElement(PacketParserU

at org.jivesoftware.smack.util.PacketParserUtils.parseMessage(PacketParserUtils.ja va:287)

at org.jivesoftware.smack.util.PacketParserUtils.parseStanza(PacketParserUtils.jav a:151)

at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMP

at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$500( 140)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPCon

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$


i dont receive the answer with the approval notification in the smack debug window, and i cant make a StanzaListener, because the error occur before

I’m using smack 4.1.4, on a 15.06 ejabberd server (

thanks in advance and if you need more information just tell me

Could you show us the stanza trace when the code in question is executed? More information how to obtain the trace can be found at,-report-an-issu e-and-possible-solve-the-problem-yourself

  1. Subscriber - PubSub Server trace:

a) Subscriber send a subscription request

<subscribe node="testNode" jid=""/>

b) Server replies with pending

<subscription jid="" node="testNode" subscription="pending"/>
  1. Server - owner trace:

a) Server sends authorization request to node owner

PubSub subscriber request

Choose whether to approve this entity’s subscription.





b) Owner approves subscription request





And then, based on XEP 0060 - Publish-Subscribe, there must be a message from the server to the subscriber, with the approval notification, but the error that i mention before, appears.

Obs: the smack debuger window tell that the error occur in the subscriber user