powered by Jive Software

<body> is producing name space exception with PacketParserUtils.parseStanza(string)


#1

After upgrading my project (ofchat) from smack 4.2 to 4.3, The following code is failing with a missing namespace exception

String xml = "<message...><body>xxxx</body></message>"
stanza = PacketParserUtils.parseStanza(xml);

After investigation, I found that the following commit may be responsible. I then hacked “PacketParserUtils.java” to add back the code that explicitly handled <body> make it work.

case "body":    // BAO
    String xmlLangBody = ParserUtils.getXmlLang(parser);
    String body = parseElementText(parser);

    if (message.getBody(xmlLangBody) == null) {
        message.addBody(xmlLangBody, body);
    }
    break;

I am not sure what the proper solution is, but the hack prevents the exception at the moment.


#2

Adding the missing namespace.

String xml = "<message xmlns='jabber:client'...><body>xxxx</body></message>"

#4

Is the correct answer. Thanks Flow