powered by Jive Software

Smack 4.4.2 - While fetching offline messages using OfflineMessageManager, gets an error with a message 'Consider adding QNAME'

  • Smack version: 4.4.2
  • Exception
W/AbstractXMPPConnection: Connection XMPPTCPConnection[x@xyz.com/587a8g38ss] (5) closed with error
    java.lang.IllegalArgumentException: The class org.jivesoftware.smackx.offline.packet.OfflineMessageInfo has no ELEMENT, NAMESPACE or QNAME member. Consider adding QNAME
        at org.jivesoftware.smack.util.XmppElementUtil.getQNameFor(XmppElementUtil.java:66)
        at org.jivesoftware.smack.packet.StanzaView.getExtension(StanzaView.java:91)
        at org.jivesoftware.smackx.offline.OfflineMessageManager$1.accept(OfflineMessageManager.java:175)
        at org.jivesoftware.smack.filter.AndFilter.accept(AndFilter.java:61)
        at org.jivesoftware.smack.StanzaCollector.processStanza(StanzaCollector.java:347)
        at org.jivesoftware.smack.AbstractXMPPConnection.invokeStanzaCollectorsAndNotifyRecvListeners(AbstractXMPPConnection.java:1612)
        at org.jivesoftware.smack.AbstractXMPPConnection.processStanza(AbstractXMPPConnection.java:1483)
        at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMPPConnection.java:1461)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1000(XMPPTCPConnection.java:130)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:969)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$700(XMPPTCPConnection.java:913)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:936)
        at java.lang.Thread.run(Thread.java:919)
     Caused by: java.lang.NoSuchFieldException: ELEMENT
        at java.lang.Class.getField(Class.java:1604)
        at org.jivesoftware.smack.util.XmppElementUtil.getQNameFor(XmppElementUtil.java:62)
        at org.jivesoftware.smack.packet.StanzaView.getExtension(StanzaView.java:91) 
        at org.jivesoftware.smackx.offline.OfflineMessageManager$1.accept(OfflineMessageManager.java:175) 
        at org.jivesoftware.smack.filter.AndFilter.accept(AndFilter.java:61) 
        at org.jivesoftware.smack.StanzaCollector.processStanza(StanzaCollector.java:347) 
        at org.jivesoftware.smack.AbstractXMPPConnection.invokeStanzaCollectorsAndNotifyRecvListeners(AbstractXMPPConnection.java:1612) 
        at org.jivesoftware.smack.AbstractXMPPConnection.processStanza(AbstractXMPPConnection.java:1483) 
        at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMPPConnection.java:1461) 
        at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1000(XMPPTCPConnection.java:130) 
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:969) 
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$700(XMPPTCPConnection.java:913) 
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:936) 
        at java.lang.Thread.run(Thread.java:919) 
  • XMPP Trace
D/SMACK: SENT (5): 
    <iq id='QCB9G-120' type='get'>
      <offline xmlns='http://jabber.org/protocol/offline'>
        <item action="view" node="2021-04-13T11:37:56.160Z"/>
      </offline>
    </iq>
D/SMACK: RECV (5): 
    <message type="chat" to="x@xyz.com/android" id="788BFD31-066A-4268-8A6F-8D3973001D95" from="y@xyz.com/ios">
      <body>
        Test
      </body>
      <active xmlns="http://jabber.org/protocol/chatstates">
      </active>
      <request xmlns="urn:xmpp:receipts">
      </request>
      <delay xmlns="urn:xmpp:delay" stamp="2021-04-13T11:37:56.151Z">
      </delay>
      <delay xmlns="urn:xmpp:delay" from="xyz.com" stamp="2021-04-13T11:37:56.160Z"/>
      <offline xmlns="http://jabber.org/protocol/offline">
        <item node="2021-04-13T11:37:56.160Z"/>
      </offline>
    </message>
  • Code Parts
private val connection = XMPPTCPConnection(config)
private val offlineMessageManager = OfflineMessageManager.getInstanceFor(connection)
offlineMessageManager.getMessages(listOf("2021-04-13T11:37:56.160Z"))

I am trying to fetch offline messages using OfflineMessageManager. There is an error while getting OfflineMessageInfo extension from received Stanza. I guess it is because of the following filter,

        StanzaFilter messageFilter = new AndFilter(PACKET_FILTER, new StanzaFilter() {
            @Override
            public boolean accept(Stanza packet) {
                OfflineMessageInfo info = packet.getExtension(OfflineMessageInfo.class);
                return nodes.contains(info.getNode());
            }
        });

This was a working way while using Smack 4.3.5, but with upgrade to Smack 4.4.2 this exception occurred.

Thanks for the detailed report. I’ve created SMACK-905.

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.