powered by Jive Software

XML parsing errors using smack 3.1.0 and pubsub

Hi all,

I have a very strange problem. When retrieving the stored items in a node I’m getting alternating items and non-item packets. I’ve enabled Smack debugging and I see the following raw output:

<iq type="result" id="z1TsQ-12" from="pubsub.hati" to="alice@hati/BlueMountain">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<items node="ruote_development/workitems/user/alice/updates">
<item id="8bca4980-e1d1-012c-4a1b-000c2916d068"><value>{&quot;description&quot;:&quot;Editar operador 0&quot;,&quot;wi_uri&quot;:&quot;/workitems/20100112-kezanimito/0_1_1_2&quot;,&quot;proc_uri&quot;:&quot;/processes/20100112-kezanimito&quot;,&quot;params&quot;:{&quot;owner-group&quot;:&quot;trafico&quot;,&quot;assigned-to&quot;:&quot;initiator&quot;,&quot;form-id&quot;:&quot;crm&quot;,&quot;form-ver&quot;:&quot;latest&quot;,&quot;immediate&quot;:true,&quot;description&quot;:&quot;crear/editar datos operador&quot;,&quot;ref&quot;:&quot;bmForm&quot;}}</value></item>
<item id="a7495ba0-e1d1-012c-4a1d-000c2916d068"><value>{&quot;description&quot;:&quot;Editar operador 0&quot;,&quot;wi_uri&quot;:&quot;/workitems/20100112-kezesutzuya/0_1_1_2&quot;,&quot;proc_uri&quot;:&quot;/processes/20100112-kezesutzuya&quot;,&quot;params&quot;:{&quot;owner-group&quot;:&quot;trafico&quot;,&quot;assigned-to&quot;:&quot;initiator&quot;,&quot;form-id&quot;:&quot;crm&quot;,&quot;form-ver&quot;:&quot;latest&quot;,&quot;immediate&quot;:true,&quot;description&quot;:&quot;crear/editar datos operador&quot;,&quot;ref&quot;:&quot;bmForm&quot;}}</value></item>
<item id="ecd581e0-e1ee-012c-4a1f-000c2916d068"><value>{&quot;description&quot;:&quot;Editar operador 0&quot;,&quot;wi_uri&quot;:&quot;/workitems/20100112-midohamohi/0_1_1_0_0_1_0_0&quot;,&quot;proc_uri&quot;:&quot;/processes/20100112-midohamohi&quot;,&quot;params&quot;:{&quot;assigned-to&quot;:&quot;initiator&quot;,&quot;form-id&quot;:&quot;crm_bloqueado&quot;,&quot;immediate&quot;:true,&quot;description&quot;:&quot;el modelo ya est\u00e1 siendo editado&quot;,&quot;ref&quot;:&quot;bmForm&quot;}}</value></item>
</items>
</pubsub>
</iq>

However, the interpreted output looks like this:

<iq id="z1TsQ-12" to="alice@hati/BlueMountain" from="pubsub.hati" type="result">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<items node='ruote_development/workitems/user/alice/updates'>
<item id='8bca4980-e1d1-012c-4a1b-000c2916d068'><value>{"description":"Editar operador 0","wi_uri":"/workitems/20100112-kezanimito/0_1_1_2","proc_uri":"/processes/20100112-kezanimito","params":{"owner-group":"trafico","assigned-to":"initiator","form-id":"crm","form-ver":"latest","immediate":true,"description":"crear/editar datos operador","ref":"bmForm"}}</value></item>
<value xmlns="http://jabber.org/protocol/pubsub"></value>
<item id='ecd581e0-e1ee-012c-4a1f-000c2916d068'><value>{"description":"Editar operador 0","wi_uri":"/workitems/20100112-midohamohi/0_1_1_0_0_1_0_0","proc_uri":"/processes/20100112-midohamohi","params":{"assigned-to":"initiator","form-id":"crm_bloqueado","immediate":true,"description":"el modelo ya est\u00e1 siendo editado","ref":"bmForm"}}</value></item>
</items>
</pubsub>
</iq>

As you can see, somewhere in Smack’s internals every other item is being lost. Any ideas? Thanks!

I’ve updated to the latest SVN version. I wrote the following minimal program:

import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smackx.pubsub.PubSubManager;
import org.jivesoftware.smackx.pubsub.LeafNode;
import org.jivesoftware.smackx.pubsub.Subscription;
import org.jivesoftware.smackx.pubsub.Item;
import java.util.List; public class ShowXmppQueue {     public static void main(String[] args) {         try {             if (args.length != 3 && args.length != 4) {                 System.err.println("Usage: java ShowXmppQueue user password host [xmpp-domain]");
                System.exit(-1);
            }             String domain = args[args.length - 1];             XMPPConnection con = new XMPPConnection(args[2]);
            con.connect();
            con.login(args[0], args[1], "ShowXmppQueue");
            PubSubManager mgr = new PubSubManager(con, "pubsub."+domain);
                        for (Subscription sub : mgr.getSubscriptions()) {                 LeafNode node = (LeafNode)mgr.getNode(sub.getNode());
                System.out.println("Node:" + node.getId());                 for (Item item : node.getItems()) {
                  System.out.println("Stored item: " + item);
                }                 /*
                List items = node.getItems();                 for (Object item : items) {                     if (item instanceof Item) {                         System.out.println("Stored item: " + ((Item)item).toXML());
                    } else {                         System.out.println("Unknown packet type: " + item);
                    }
                }
                */
            }
        } catch (Exception ex) {             ex.printStackTrace();
        }
    }
}

This gives me the following output:

Node:ruote_development/workitems/user/alice/updates
Stored item: org.jivesoftware.smackx.pubsub.PayloadItem | Content [<item id='7d7ee3d0-e300-012c-4a75-000c2916d068'><value>{&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;wi_uri&quot;:&quot;/workitems/20100114-dudegukumu/0_1_0&quot;,&quot;proc_uri&quot;:&quot;/processes/20100114-dudegukumu&quot;,&quot;params&quot;:{&quot;form-id&quot;:&quot;crm_busqueda&quot;,&quot;assigned-to&quot;:&quot;initiator&quot;,&quot;form-ver&quot;:&quot;latest&quot;,&quot;immediate&quot;:true,&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;ref&quot;:&quot;bmForm&quot;}}</value></item>]

java.lang.ClassCastException: org.jivesoftware.smack.packet.DefaultPacketExtension cannot be cast to org.jivesoftware.smackx.pubsub.Item

 at ShowXmppQueue.main(ShowXmppQueue.java:29)

Which is patently wrong since LeafNode#getItems() is declared as public List getItems()

If I comment out the for loop and uncomment the other for loop, I get the following:

Node:ruote_development/workitems/user/alice/updates
Stored item: <item id='7d7ee3d0-e300-012c-4a75-000c2916d068'><value>{&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;wi_uri&quot;:&quot;/workitems/20100114-dudegukumu/0_1_0&quot;,&quot;proc_uri&quot;:&quot;/processes/20100114-dudegukumu&quot;,&quot;params&quot;:{&quot;form-id&quot;:&quot;crm_busqueda&quot;,&quot;assigned-to&quot;:&quot;initiator&quot;,&quot;form-ver&quot;:&quot;latest&quot;,&quot;immediate&quot;:true,&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;ref&quot;:&quot;bmForm&quot;}}</value></item>
Unknown packet type: org.jivesoftware.smack.packet.DefaultPacketExtension@56f449b8
Stored item: <item id='c832d780-e32e-012c-4a77-000c2916d068'><value>{&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;wi_uri&quot;:&quot;/workitems/20100114-hikazakida/0_1_0&quot;,&quot;proc_uri&quot;:&quot;/processes/20100114-hikazakida&quot;,&quot;params&quot;:{&quot;form-id&quot;:&quot;crm_busqueda&quot;,&quot;assigned-to&quot;:&quot;initiator&quot;,&quot;form-ver&quot;:&quot;latest&quot;,&quot;immediate&quot;:true,&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;ref&quot;:&quot;bmForm&quot;}}</value></item>
Unknown packet type: org.jivesoftware.smack.packet.DefaultPacketExtension@599855ed
Stored item: <item id='b221c120-e3c9-012c-4a79-000c2916d068'><value>{&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;wi_uri&quot;:&quot;/workitems/20100115-duderikode/0_1_0&quot;,&quot;proc_uri&quot;:&quot;/processes/20100115-duderikode&quot;,&quot;params&quot;:{&quot;form-id&quot;:&quot;crm_busqueda&quot;,&quot;assigned-to&quot;:&quot;initiator&quot;,&quot;form-ver&quot;:&quot;latest&quot;,&quot;immediate&quot;:true,&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;ref&quot;:&quot;bmForm&quot;}}</value></item>
Unknown packet type: org.jivesoftware.smack.packet.DefaultPacketExtension@bc794cc
Stored item: <item id='020c7cc0-e55c-012c-4a7b-000c2916d068'><value>{&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;wi_uri&quot;:&quot;/workitems/20100117-dudememuza/0_1_0&quot;,&quot;proc_uri&quot;:&quot;/processes/20100117-dudememuza&quot;,&quot;params&quot;:{&quot;form-id&quot;:&quot;crm_busqueda&quot;,&quot;assigned-to&quot;:&quot;initiator&quot;,&quot;form-ver&quot;:&quot;latest&quot;,&quot;immediate&quot;:true,&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;ref&quot;:&quot;bmForm&quot;}}</value></item>
Unknown packet type: org.jivesoftware.smack.packet.DefaultPacketExtension@72adf5be
Stored item: <item id='82086a70-e65a-012c-4a83-000c2916d068'><value>{&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;wi_uri&quot;:&quot;/workitems/20100118-hopujekujo/0_1_0&quot;,&quot;proc_uri&quot;:&quot;/processes/20100118-hopujekujo&quot;,&quot;params&quot;:{&quot;form-id&quot;:&quot;crm_busqueda&quot;,&quot;assigned-to&quot;:&quot;initiator&quot;,&quot;form-ver&quot;:&quot;latest&quot;,&quot;immediate&quot;:true,&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;ref&quot;:&quot;bmForm&quot;}}</value></item>
Unknown packet type: org.jivesoftware.smack.packet.DefaultPacketExtension@3b5b123b
Stored item: <item id='43f00a10-e66f-012c-4a85-000c2916d068'><value>{&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;wi_uri&quot;:&quot;/workitems/20100118-jijuhatsuru/0_1_0&quot;,&quot;proc_uri&quot;:&quot;/processes/20100118-jijuhatsuru&quot;,&quot;params&quot;:{&quot;form-id&quot;:&quot;crm_busqueda&quot;,&quot;assigned-to&quot;:&quot;initiator&quot;,&quot;form-ver&quot;:&quot;latest&quot;,&quot;immediate&quot;:true,&quot;description&quot;:&quot;Selecci\u00f3n operador&quot;,&quot;ref&quot;:&quot;bmForm&quot;}}</value></item>

Again, we see that every other packet is parsed wrong, giving a DefaultPacketExtension instead of an Item. Checking this with a different client (in Ruby) I get the correct output:

persisted USR item: c33646b0-e66a-012c-4a84-000c2916d068<value>{&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;wi_uri&amp;quot;:&amp;quot;/workitems/20100118-jenitoyota/0_1_0&amp;quot;,&amp;quot;proc_uri&amp;quot;:&amp;quot;/processes/20100118-jenitoyota&amp;quot;,&amp;quot;params&amp;quot;:{&amp;quot;form-id&amp;quot;:&amp;quot;crm_busqueda&amp;quot;,&amp;quot;assigned-to&amp;quot;:&amp;quot;initiator&amp;quot;,&amp;quot;form-ver&amp;quot;:&amp;quot;latest&amp;quot;,&amp;quot;immediate&amp;quot;:true,&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;ref&amp;quot;:&amp;quot;bmForm&amp;quot;}}</value>
----
persisted USR item: 82086a70-e65a-012c-4a83-000c2916d068<value>{&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;wi_uri&amp;quot;:&amp;quot;/workitems/20100118-hopujekujo/0_1_0&amp;quot;,&amp;quot;proc_uri&amp;quot;:&amp;quot;/processes/20100118-hopujekujo&amp;quot;,&amp;quot;params&amp;quot;:{&amp;quot;form-id&amp;quot;:&amp;quot;crm_busqueda&amp;quot;,&amp;quot;assigned-to&amp;quot;:&amp;quot;initiator&amp;quot;,&amp;quot;form-ver&amp;quot;:&amp;quot;latest&amp;quot;,&amp;quot;immediate&amp;quot;:true,&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;ref&amp;quot;:&amp;quot;bmForm&amp;quot;}}</value>
----
persisted USR item: 43f00a10-e66f-012c-4a85-000c2916d068<value>{&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;wi_uri&amp;quot;:&amp;quot;/workitems/20100118-jijuhatsuru/0_1_0&amp;quot;,&amp;quot;proc_uri&amp;quot;:&amp;quot;/processes/20100118-jijuhatsuru&amp;quot;,&amp;quot;params&amp;quot;:{&amp;quot;form-id&amp;quot;:&amp;quot;crm_busqueda&amp;quot;,&amp;quot;assigned-to&amp;quot;:&amp;quot;initiator&amp;quot;,&amp;quot;form-ver&amp;quot;:&amp;quot;latest&amp;quot;,&amp;quot;immediate&amp;quot;:true,&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;ref&amp;quot;:&amp;quot;bmForm&amp;quot;}}</value>
----
persisted USR item: 2ca850a0-e625-012c-4a7c-000c2916d068<value>{&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;wi_uri&amp;quot;:&amp;quot;/workitems/20100118-dudemodime/0_1_0&amp;quot;,&amp;quot;proc_uri&amp;quot;:&amp;quot;/processes/20100118-dudemodime&amp;quot;,&amp;quot;params&amp;quot;:{&amp;quot;form-id&amp;quot;:&amp;quot;crm_busqueda&amp;quot;,&amp;quot;assigned-to&amp;quot;:&amp;quot;initiator&amp;quot;,&amp;quot;form-ver&amp;quot;:&amp;quot;latest&amp;quot;,&amp;quot;immediate&amp;quot;:true,&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;ref&amp;quot;:&amp;quot;bmForm&amp;quot;}}</value>
----
persisted USR item: 020c7cc0-e55c-012c-4a7b-000c2916d068<value>{&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;wi_uri&amp;quot;:&amp;quot;/workitems/20100117-dudememuza/0_1_0&amp;quot;,&amp;quot;proc_uri&amp;quot;:&amp;quot;/processes/20100117-dudememuza&amp;quot;,&amp;quot;params&amp;quot;:{&amp;quot;form-id&amp;quot;:&amp;quot;crm_busqueda&amp;quot;,&amp;quot;assigned-to&amp;quot;:&amp;quot;initiator&amp;quot;,&amp;quot;form-ver&amp;quot;:&amp;quot;latest&amp;quot;,&amp;quot;immediate&amp;quot;:true,&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;ref&amp;quot;:&amp;quot;bmForm&amp;quot;}}</value>
----
persisted USR item: dd386e50-e492-012c-4a7a-000c2916d068<value>{&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;wi_uri&amp;quot;:&amp;quot;/workitems/20100116-duderukuchi/0_1_0&amp;quot;,&amp;quot;proc_uri&amp;quot;:&amp;quot;/processes/20100116-duderukuchi&amp;quot;,&amp;quot;params&amp;quot;:{&amp;quot;form-id&amp;quot;:&amp;quot;crm_busqueda&amp;quot;,&amp;quot;assigned-to&amp;quot;:&amp;quot;initiator&amp;quot;,&amp;quot;form-ver&amp;quot;:&amp;quot;latest&amp;quot;,&amp;quot;immediate&amp;quot;:true,&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;ref&amp;quot;:&amp;quot;bmForm&amp;quot;}}</value>
----
persisted USR item: 3f15f8f0-e340-012c-4a78-000c2916d068<value>{&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;wi_uri&amp;quot;:&amp;quot;/workitems/20100114-jamunojisa/0_1_0&amp;quot;,&amp;quot;proc_uri&amp;quot;:&amp;quot;/processes/20100114-jamunojisa&amp;quot;,&amp;quot;params&amp;quot;:{&amp;quot;form-id&amp;quot;:&amp;quot;crm_busqueda&amp;quot;,&amp;quot;assigned-to&amp;quot;:&amp;quot;initiator&amp;quot;,&amp;quot;form-ver&amp;quot;:&amp;quot;latest&amp;quot;,&amp;quot;immediate&amp;quot;:true,&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;ref&amp;quot;:&amp;quot;bmForm&amp;quot;}}</value>
----
persisted USR item: 1b45d7f0-e329-012c-4a76-000c2916d068<value>{&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;wi_uri&amp;quot;:&amp;quot;/workitems/20100114-hejutapura/0_1_0&amp;quot;,&amp;quot;proc_uri&amp;quot;:&amp;quot;/processes/20100114-hejutapura&amp;quot;,&amp;quot;params&amp;quot;:{&amp;quot;form-id&amp;quot;:&amp;quot;crm_busqueda&amp;quot;,&amp;quot;assigned-to&amp;quot;:&amp;quot;initiator&amp;quot;,&amp;quot;form-ver&amp;quot;:&amp;quot;latest&amp;quot;,&amp;quot;immediate&amp;quot;:true,&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;ref&amp;quot;:&amp;quot;bmForm&amp;quot;}}</value>
----
persisted USR item: c832d780-e32e-012c-4a77-000c2916d068<value>{&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;wi_uri&amp;quot;:&amp;quot;/workitems/20100114-hikazakida/0_1_0&amp;quot;,&amp;quot;proc_uri&amp;quot;:&amp;quot;/processes/20100114-hikazakida&amp;quot;,&amp;quot;params&amp;quot;:{&amp;quot;form-id&amp;quot;:&amp;quot;crm_busqueda&amp;quot;,&amp;quot;assigned-to&amp;quot;:&amp;quot;initiator&amp;quot;,&amp;quot;form-ver&amp;quot;:&amp;quot;latest&amp;quot;,&amp;quot;immediate&amp;quot;:true,&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;ref&amp;quot;:&amp;quot;bmForm&amp;quot;}}</value>
----
persisted USR item: b221c120-e3c9-012c-4a79-000c2916d068<value>{&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;wi_uri&amp;quot;:&amp;quot;/workitems/20100115-duderikode/0_1_0&amp;quot;,&amp;quot;proc_uri&amp;quot;:&amp;quot;/processes/20100115-duderikode&amp;quot;,&amp;quot;params&amp;quot;:{&amp;quot;form-id&amp;quot;:&amp;quot;crm_busqueda&amp;quot;,&amp;quot;assigned-to&amp;quot;:&amp;quot;initiator&amp;quot;,&amp;quot;form-ver&amp;quot;:&amp;quot;latest&amp;quot;,&amp;quot;immediate&amp;quot;:true,&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;ref&amp;quot;:&amp;quot;bmForm&amp;quot;}}</value>
----
persisted USR item: 7d7ee3d0-e300-012c-4a75-000c2916d068<value>{&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;wi_uri&amp;quot;:&amp;quot;/workitems/20100114-dudegukumu/0_1_0&amp;quot;,&amp;quot;proc_uri&amp;quot;:&amp;quot;/processes/20100114-dudegukumu&amp;quot;,&amp;quot;params&amp;quot;:{&amp;quot;form-id&amp;quot;:&amp;quot;crm_busqueda&amp;quot;,&amp;quot;assigned-to&amp;quot;:&amp;quot;initiator&amp;quot;,&amp;quot;form-ver&amp;quot;:&amp;quot;latest&amp;quot;,&amp;quot;immediate&amp;quot;:true,&amp;quot;description&amp;quot;:&amp;quot;Selecci\u00f3n operador&amp;quot;,&amp;quot;ref&amp;quot;:&amp;quot;bmForm&amp;quot;}}</value>
----

Sorry, my bad.

I noticed that when I fixed the OpenFire issue that caused the repeating input, but forgot to log a defect against it under Smack. I will do that right now and try to get it fixed for next week.

There - logged as SMACK-288

Great! Thanks!

This has now been fixed in trunk.