powered by Jive Software

Can't addUser with ServiceAdministrationManager on ejabberd


#1

Hi,

First, a big hello to the IgniteRealtime Smack community :slight_smile:

So the problem is… I wanted to create users with Smack (java7) using the Service Administration extension (I’m connected to ejabberd 16 as an admin user) The code is as follows:

	ServiceAdministrationManager serviceAdministrationManager = ServiceAdministrationManager.getInstanceFor( connection );
        EntityBareJid userJid = JidCreate.entityBareFrom( Localpart.from( "newuser" ), connection.getXMPPServiceDomain() );
        serviceAdministrationManager.addUser( userJid, chatUserPassword );

And I get the following exception:

Apr 12, 2018 9:37:18 AM org.jivesoftware.smack.AbstractXMPPConnection callConnectionClosedOnErrorListener
09:37:18 XMPPConnection closed due to an exception (XMPPTCPConnection[admin@xxx.net/2136745900047433830418] (0))java.lang.NullPointerException
WARNING: Connection XMPPTCPConnection[admin@xxx.net/2136745900047433830418] (0) closed with error
java.lang.NullPointerException
	at org.jivesoftware.smackx.xdata.packet.DataForm$Type.fromString(DataForm.java:68)
	at org.jivesoftware.smackx.xdata.packet.DataForm$Type.fromString(DataForm.java:68)
	at org.jivesoftware.smackx.xdata.provider.DataFormProvider.parse(DataFormProvider.java:50)
	at org.jivesoftware.smackx.xdata.provider.DataFormProvider.parse(DataFormProvider.java:50)
	at org.jivesoftware.smackx.xdata.provider.DataFormProvider.parse(DataFormProvider.java:43)
	at org.jivesoftware.smackx.xdata.provider.DataFormProvider.parse(DataFormProvider.java:43)
	at org.jivesoftware.smack.provider.Provider.parse(Provider.java:32)
	at org.jivesoftware.smack.provider.Provider.parse(Provider.java:32)
	at org.jivesoftware.smackx.commands.provider.AdHocCommandDataProvider.parse(AdHocCommandDataProvider.java:97)
	at org.jivesoftware.smackx.commands.provider.AdHocCommandDataProvider.parse(AdHocCommandDataProvider.java:97)
	at org.jivesoftware.smackx.commands.provider.AdHocCommandDataProvider.parse(AdHocCommandDataProvider.java:38)
	at org.jivesoftware.smack.provider.Provider.parse(Provider.java:32)
	at org.jivesoftware.smackx.commands.provider.AdHocCommandDataProvider.parse(AdHocCommandDataProvider.java:38)
	at org.jivesoftware.smack.util.PacketParserUtils.parseIQ(PacketParserUtils.java:633)
	at org.jivesoftware.smack.util.PacketParserUtils.parseStanza(PacketParserUtils.java:153)
	at org.jivesoftware.smack.provider.Provider.parse(Provider.java:32)
	at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMPPConnection.java:1054)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$500(XMPPTCPConnection.java:151)
	at org.jivesoftware.smack.util.PacketParserUtils.parseIQ(PacketParserUtils.java:633)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1038)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:994)
	at org.jivesoftware.smack.util.PacketParserUtils.parseStanza(PacketParserUtils.java:153)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:1010)
	at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMPPConnection.java:1054)
	at java.lang.Thread.run(Thread.java:748)

I also found this report from 2017 which looks like the same problem but it’s reported against integration tests:
https://issues.igniterealtime.org/browse/SMACK-763

It fails on command.exectue() in addUser.

Here’s part of the log, if it helps:

09:37:17 SENT (0): <r xmlns='urn:xmpp:sm:3'/>
09:37:17 SENT (0): <iq to='xxx.net' id='71Dc7-9' type='set'><command xmlns='http://jabber.org/protocol/commands' node='http://jabber.org/protocol/admin#add-user' action='execute'></command></iq>
09:37:18 RECV (0): <iq from='admin@xxx.net' to='admin@xxx.net/2136745900047433830418' id='71Dc7-5' type='result'><query xmlns='jabber:iq:roster'><item subscription='both' name='L' jid='l@xxx.net'><group>SharedRoster</group></item><item subscription='both' name='M' jid='m@xxx.net'><group>SharedRoster</group></item></query></iq>
09:37:18 RECV (0): <r xmlns='urn:xmpp:sm:3'/>
09:37:18 SENT (0): <a xmlns='urn:xmpp:sm:3' h='1'/>
09:37:18 RECV (0): <a xmlns='urn:xmpp:sm:3' h='3'/>
09:37:18 RECV (0): <presence from='admin@xxx.net/2136745900047433830418' to='admin@xxx.net/2136745900047433830418' xml:lang='en' id='71Dc7-6'><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.igniterealtime.org/projects/smack' ver='NfJ3flI83zSdUDzCEICtbypursw='/></presence>
09:37:18 RECV (0): <iq from='xxx.net' to='admin@xxx.net/2136745900047433830418' id='71Dc7-9' type='result'><command xmlns='http://jabber.org/protocol/commands' sessionid='2018-04-12T07:37:22.984989Z' node='http://jabber.org/protocol/admin#add-user' status='executing'><x xmlns='jabber:x:data'><field type='hidden' var='FORM_TYPE'><value>http://jabber.org/protocol/admin</value></field><title>Add User</title><field type='jid-single' label='Jabber ID' var='accountjid'><required/></field><field type='text-private' label='Password' var='password'><required/></field><field type='text-private' label='Password Verification' var='password-verify'><required/></field></x></command></iq>

Another noob question. In the Smack Extenstion Users Manual (http://download.igniterealtime.org/smack/docs/latest/documentation/extensions/index.html) some extensions have links to documentation (e.g. Data Forms, Privacy List, Service Discovery), but others don’t (Last Activity, Flexible Offline Message Retrieval,… and Service Administration). Does this mean the extension is not supported/finished or that it just lacks documentation?


#2

Which Smack version is this?

That


#3

@Flow: Ahh… the version, sorry…

    <properties>
        <smack.version>4.2.3</smack.version>
    </properties>
        <dependency>
            <groupId>org.igniterealtime.smack</groupId>
            <artifactId>smack-java7</artifactId>
            <version>${smack.version}</version>
        </dependency>

        <dependency>
            <groupId>org.igniterealtime.smack</groupId>
            <artifactId>smack-tcp</artifactId>
            <version>${smack.version}</version>
        </dependency>

        <dependency>
            <groupId>org.igniterealtime.smack</groupId>
            <artifactId>smack-im</artifactId>
            <version>${smack.version}</version>
        </dependency>

        <dependency>
            <groupId>org.igniterealtime.smack</groupId>
            <artifactId>smack-extensions</artifactId>
            <version>${smack.version}</version>
        </dependency>

I think I also tried with 4.2.0, was the same.

ejabberd is 16.09-4 (on Debian 9)


#4

That sounds like SMACK-804. You could try a Smack 4.2.4-SNAPSHOT and see if the issue still exists?


#5

@Flow I tried 4.2.4-SNAPSHOT (smack-extensions-4.2.4-20180409.065242-3.jar) - same problem.

Adding a user with psi works, though.


#6

@Flow I tested this also with ejabberd 18.01 - same problem: server says “Unexpected action”:

<iq xml:lang='en' to='admin@xxx.net/1543357606459703091363' from='xxx.net' type='error' id='cc3FT-13'><command action='next' sessionid='2018-04-17T19:40:00.300618Z' node='http://jabber.org/protocol/admin#add-user' xmlns='http://jabber.org/protocol/commands'><x type='submit' xmlns='jabber:x:data'><field var='FORM_TYPE' type='hidden'><value>http://jabber.org/protocol/admin</value></field><field var='accountjid' type='jid-single'><value>mujo@xxx.net</value></field><field var='password' type='text-private'><value>secret</value></field><field var='password-verify' type='text-private'><value>secret</value></field></x></command><error code='400' type='modify'><bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Unexpected action</text></error></iq>

#7

@Flow I tried to create the user both with Smack and Psi, the difference is that Smack adds action=‘next’ to the command (2nd line of the iq stanza).

Smack:
<iq to='xxx.net' id='JDjuI-13' type='set'>
<command xmlns='http://jabber.org/protocol/commands' node='http://jabber.org/protocol/admin#add-user' sessionid='2018-04-17T19:49:54.032651Z' action='next'>
<x xmlns='jabber:x:data' type='submit'>
<field var='FORM_TYPE' type='hidden'>
<value>http://jabber.org/protocol/admin</value>
</field>
<field var='accountjid' type='jid-single'>
<value>mujo@xxx.net</value>
</field>
<field var='password' type='text-private'>
<value>secret</value>
</field>
<field var='password-verify' type='text-private'>
<value>secret</value>
</field>
</x>
</command>
</iq>


Psi:
<iq to="xxx.net" id="aaeea" type="set">
<command xmlns="http://jabber.org/protocol/commands" node="http://jabber.org/protocol/admin#add-user" sessionid="2018-04-17T19:53:35.946219Z">
<x xmlns="jabber:x:data" type="submit">
<field var="FORM_TYPE" type="hidden">
<value>http://jabber.org/protocol/admin</value>
</field>
<field var="accountjid" type="jid-single">
<value>mujo@xxx.net</value>
</field>
<field var="password" type="text-private">
<value>secret</value>
</field>
<field var="password-verify" type="text-private">
<value>secret</value>
</field>
</x>
</command>
</iq>