我正在使用converse.js
并尝试使用隐私列表。我试图发送这个智商:
<body rid="2993056535" xmlns="http://jabber.org/protocol/httpbind" sid="578oe88nm1">
<iq from="alex3@ofb2" type="set" id="active1" xmlns="jabber:client">
<query xmlns="jabber:iq:privacy"/>
</iq>
</body>
这是服务器给我的回复:
<body xmlns="http://jabber.org/protocol/httpbind" ack="2993056535">
<iq xmlns="jabber:client" type="error" id="active1" to="alex3@ofb2/converse.js-90734653">
<query xmlns="jabber:iq:privacy"/>
<error code="500" type="wait">
<internal-server-error xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
</error>
</iq>
</body>
在服务器日志中,我看到了这个例外:
2016.02.19 12:49:00 org.jivesoftware.openfire.handler.IQHandler - Internal server error
java.lang.NullPointerException
at org.jivesoftware.openfire.handler.IQPrivacyHandler.handleIQ(IQPrivacyHandler.java:120)
at org.jivesoftware.openfire.handler.IQHandler.process(IQHandler.java:66)
at org.jivesoftware.openfire.IQRouter.handle(IQRouter.java:372)
at org.jivesoftware.openfire.IQRouter.route(IQRouter.java:115)
at org.jivesoftware.openfire.spi.PacketRouterImpl.route(PacketRouterImpl.java:78)
at org.jivesoftware.openfire.SessionPacketRouter.route(SessionPacketRouter.java:108)
at org.jivesoftware.openfire.SessionPacketRouter.route(SessionPacketRouter.java:67)
at org.jivesoftware.openfire.http.HttpSession.sendPendingPackets(HttpSession.java:639)
at org.jivesoftware.openfire.http.HttpSession$HttpPacketSender.run(HttpSession.java:1270)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
出了什么问题?
答案 0 :(得分:1)
stacktrace points to these lines:
// Privacy list handling (create/edit/delete)
Element list = child.element("list");
String listName = list.attributeValue("name");
也就是说,它会查找子元素<list>
,并在无法找到它时崩溃。
那为什么要寻找呢?事实证明,如果IQ具有类型set
(并且<default>
和<active>
子元素都不是),则这是分支。但是,如XEP-0016中所述,要获取现有隐私列表的名称,您需要发送类型为get
的IQ。您的请求应该是这样的:
<iq from='romeo@example.net/orchard' type='get' id='getlist1'>
<query xmlns='jabber:iq:privacy'/>
</iq>