NullPointerException when user joins MUC

I am currently using Smack version 4.3.1 and building an Android application.

When creating a MUC I use the following

MultiUserChatManager mucManager = MultiUserChatManager.getInstanceFor(mConnection);
                        MultiUserChat muc = mucManager.getMultiUserChat(JidCreate.entityBareFrom(uniqueId + Constants.CHAT_MUC_RESOURCE_PREFIX + mConnection.getUser().asBareJid().getDomain().toString()));
                        Resourcepart nickname = Resourcepart.from(mConnection.getUser().asBareJid().toString());


                        Form form = muc.getConfigurationForm();
                        Form submitForm = form.createAnswerForm();

                        for (FormField formField : form.getFields()) {


                        for (String jid : jidList) {
                            muc.invite(JidCreate.entityBareFrom(jid), "");

It creates a MUC just fine and will send out invites. User’s using the same version connecting via other Xmpp connections other than Smack can join just fine and Smack can handle it but when a user joins from an older version of Smack the app crashes with the following stacktrace. This happens with tries to handle the presence of the user joining.

New Fatal Issue - line 226 - Android com.nightly SNAPSHOT-20190430 (15566843

 --------- beginning of crash
05-01 13:59:47.965 11806-1395/ E/AndroidRuntime: FATAL EXCEPTION: Smack Cached Executor
Process:, PID: 11806
java.lang.NullPointerException: Attempt to invoke virtual method 'org.jivesoftware.smackx.muc.MUCAffiliation org.jivesoftware.smackx.muc.packet.MUCItem.getAffiliation()' on a null object reference
at org.jivesoftware.smackx.muc.MultiUserChat$3$
at org.jivesoftware.smack.AsyncButOrdered$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$

We cannot update the Smack version of the other app since we do not have ownership over it.

Any help on how to handle this would be much appreciated! Thank you.

Is there any other information that I might be able to give to get some help on this?

Yes: The stanza that is causing this. My guess is that it is an presence without muc#user.

See also,-report-an-issue-and-possible-solve-the-problem-yourself

I apologize…

Here’s the stanza that’s causing it. It looks like there’s two muc#user extension and Smack is just pulling the first one.

<presence xmlns='jabber:client' to='' from='' id='skCD7-58'>
	<x xmlns=''></x>
	<x xmlns=''>
		<item affiliation='none' jid='' nick='' role='participant'>
	<x xmlns='urn:xmpp:SERVER:userinfo' xmlns:stream=''>
		<firstname xmlns:stream=''>First</firstname>
		<lastname xmlns:stream=''>Last</lastname>

That looks like something you want to report to the vendor if the MUC service implementation.

But Smack should not crash. This is possibly an oversight in the implementation. I’ll look into it.

Created SMACK-896.

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