powered by Jive Software

Crash doing SmackConfiguration.getVersion in production, Smack-4.1.6

We’re having crashes in an application that uses Smack-4.1.6 (I know is not the latest version, but checking the changelog I think it should not be relevant for the crash), there are different stacktraces, but they seem to be related with a wrong ClassLoader, here are some examples:

StackTrace1:

java.lang.ExceptionInInitializerError
	at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96)
	at org.jivesoftware.smack.provider.ProviderManager.<clinit>(ProviderManager.java:121)
	at com.mycompany.xmpp.IQProvidersRegistrar.registerTangle(IQProvidersRegistrar.java:43)
	at com.mycompany.xmpp.voip.receivers.util.TangleIQParser.<init>(TangleIQParser.java:23)
	at com.mycompany.xmpp.voip.receivers.util.TangleIQParser_Factory.get(TangleIQParser_Factory.java:18)
	at com.mycompany.xmpp.voip.receivers.util.TangleIQParser_Factory.get(TangleIQParser_Factory.java:8)
	at com.mycompany.xmpp.XmppModule_ProvideTangleIQExternalReceiverFactory.get(XmppModule_ProvideTangleIQExternalReceiverFactory.java:35)
	at com.mycompany.xmpp.XmppModule_ProvideTangleIQExternalReceiverFactory.get(XmppModule_ProvideTangleIQExternalReceiverFactory.java:11)
	at com.mycompany.messenger.notifications.push.notifications.processor.VoipPushProcessor_Factory.get(VoipPushProcessor_Factory.java:26)
	at com.mycompany.messenger.notifications.push.notifications.processor.VoipPushProcessor_Factory.get(VoipPushProcessor_Factory.java:9)
	at com.mycompany.messenger.notifications.fcm.FcmPushHandler_Factory.get(FcmPushHandler_Factory.java:75)
	at com.mycompany.messenger.notifications.fcm.FcmPushHandler_Factory.get(FcmPushHandler_Factory.java:15)
	at com.mycompany.messenger.notifications.fcm.FcmIntentService_MembersInjector.injectMembers(FcmIntentService_MembersInjector.java:68)
	at com.mycompany.messenger.notifications.fcm.FcmIntentService_MembersInjector.injectMembers(FcmIntentService_MembersInjector.java:12)
	at com.mycompany.messenger.core.ioc.DaggerApplicationInjectionComponent$notifications_fcm_FcmIntentService_InjectionComponentImpl.inject(DaggerApplicationInjectionComponent.java:34756)
	at com.mycompany.messenger.core.ioc.DaggerApplicationInjectionComponent$notifications_fcm_FcmIntentService_InjectionComponentImpl.inject(DaggerApplicationInjectionComponent.java:34673)
	at com.mycompany.messenger.notifications.fcm.FcmIntentService.buildInjectionComponentAndInject(FcmIntentService.java:114)
	at com.mycompany.messenger.notifications.fcm.FcmIntentService.onCreate(FcmIntentService.java:41)
	at android.app.ActivityThread.handleCreateService(ActivityThread.java:2584)
	at android.app.ActivityThread.access$1800(ActivityThread.java:142)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1285)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:136)
	at android.app.ActivityThread.main(ActivityThread.java:5118)
	at java.lang.reflect.Method.invokeNative(Method.java)
	at java.lang.reflect.Method.invoke(Method.java:515)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
	at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.IllegalStateException: java.lang.IllegalArgumentException: is == null
	at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:119)
	... 29 more
Caused by: java.lang.IllegalArgumentException: is == null
	at org.kxml2.io.KXmlParser.setInput(KXmlParser.java:1625)
	at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:155)
	at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:148)
	at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:116)
	... 29 more

StackTrace2:

java.lang.NoClassDefFoundError: org.jivesoftware.smack.SmackInitialization
	at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96)
	at org.jivesoftware.smack.provider.ProviderManager.<clinit>(ProviderManager.java:121)
	at com.mycompany.xmpp.IQProvidersRegistrar.registerTangle(IQProvidersRegistrar.java:43)
	at com.mycompany.xmpp.voip.receivers.util.TangleIQParser.<init>(TangleIQParser.java:23)
	at com.mycompany.xmpp.voip.receivers.util.TangleIQParser_Factory.get(TangleIQParser_Factory.java:18)
	at com.mycompany.xmpp.voip.receivers.util.TangleIQParser_Factory.get(TangleIQParser_Factory.java:8)
	at com.mycompany.xmpp.XmppModule_ProvideTangleIQExternalReceiverFactory.get(XmppModule_ProvideTangleIQExternalReceiverFactory.java:33)
	at com.mycompany.xmpp.XmppModule_ProvideTangleIQExternalReceiverFactory.get(XmppModule_ProvideTangleIQExternalReceiverFactory.java:11)
	at com.mycompany.messenger.notifications.push.notifications.processor.VoipPushProcessor_Factory.get(VoipPushProcessor_Factory.java:38)
	at com.mycompany.messenger.notifications.push.notifications.processor.VoipPushProcessor_Factory.get(VoipPushProcessor_Factory.java:10)
	at com.mycompany.messenger.notifications.gcm.GcmPushHandler_Factory.get(GcmPushHandler_Factory.java:73)
	at com.mycompany.messenger.notifications.gcm.GcmPushHandler_Factory.get(GcmPushHandler_Factory.java:14)
	at com.mycompany.messenger.notifications.gcm.GcmIntentService_MembersInjector.injectMembers(GcmIntentService_MembersInjector.java:72)
	at com.mycompany.messenger.notifications.gcm.GcmIntentService_MembersInjector.injectMembers(GcmIntentService_MembersInjector.java:12)
	at com.mycompany.messenger.core.ioc.DaggerApplicationInjectionComponent$notifications_gcm_GcmIntentService_InjectionComponentImpl.inject(DaggerApplicationInjectionComponent.java:28081)
	at com.mycompany.messenger.core.ioc.DaggerApplicationInjectionComponent$notifications_gcm_GcmIntentService_InjectionComponentImpl.inject(DaggerApplicationInjectionComponent.java:27977)
	at com.mycompany.messenger.notifications.gcm.GcmIntentService.buildInjectionComponentAndInject(GcmIntentService.java:111)
	at com.mycompany.messenger.notifications.gcm.GcmIntentService.onCreate(GcmIntentService.java:40)
	at android.app.ActivityThread.handleCreateService(ActivityThread.java:2738)
	at android.app.ActivityThread.access$1800(ActivityThread.java:148)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1366)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5274)
	at java.lang.reflect.Method.invoke(Method.java)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)

StackTrace3:

java.lang.ExceptionInInitializerError
	at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96)
	at org.jivesoftware.smack.provider.ProviderManager.<clinit>(ProviderManager.java:121)
	at com.mycompany.xmpp.IQProvidersRegistrar.registerTangle(IQProvidersRegistrar.java:43)
	at com.mycompany.xmpp.voip.receivers.util.TangleIQParser.<init>(TangleIQParser.java:23)
	at com.mycompany.xmpp.voip.receivers.util.TangleIQParser_Factory.get(TangleIQParser_Factory.java:18)
	at com.mycompany.xmpp.voip.receivers.util.TangleIQParser_Factory.get(TangleIQParser_Factory.java:8)
	at com.mycompany.xmpp.XmppModule_ProvideTangleIQExternalReceiverFactory.get(XmppModule_ProvideTangleIQExternalReceiverFactory.java:35)
	at com.mycompany.xmpp.XmppModule_ProvideTangleIQExternalReceiverFactory.get(XmppModule_ProvideTangleIQExternalReceiverFactory.java:11)
	at com.mycompany.messenger.notifications.push.notifications.processor.VoipPushProcessor_Factory.get(VoipPushProcessor_Factory.java:26)
	at com.mycompany.messenger.notifications.push.notifications.processor.VoipPushProcessor_Factory.get(VoipPushProcessor_Factory.java:9)
	at com.mycompany.messenger.notifications.fcm.FcmPushHandler_Factory.get(FcmPushHandler_Factory.java:81)
	at com.mycompany.messenger.notifications.fcm.FcmPushHandler_Factory.get(FcmPushHandler_Factory.java:16)
	at com.mycompany.messenger.notifications.fcm.FcmIntentService_MembersInjector.injectMembers(FcmIntentService_MembersInjector.java:68)
	at com.mycompany.messenger.notifications.fcm.FcmIntentService_MembersInjector.injectMembers(FcmIntentService_MembersInjector.java:12)
	at com.mycompany.messenger.core.ioc.DaggerApplicationInjectionComponent$notifications_fcm_FcmIntentService_InjectionComponentImpl.inject(DaggerApplicationInjectionComponent.java:38429)
	at com.mycompany.messenger.core.ioc.DaggerApplicationInjectionComponent$notifications_fcm_FcmIntentService_InjectionComponentImpl.inject(DaggerApplicationInjectionComponent.java:38339)
	at com.mycompany.messenger.notifications.fcm.FcmIntentService.buildInjectionComponentAndInject(FcmIntentService.java:114)
	at com.mycompany.messenger.notifications.fcm.FcmIntentService.onCreate(FcmIntentService.java:41)
	at android.app.ActivityThread.handleCreateService(ActivityThread.java:2934)
	at android.app.ActivityThread.access$1900(ActivityThread.java:154)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1474)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:234)
	at android.app.ActivityThread.main(ActivityThread.java:5526)
	at java.lang.reflect.Method.invoke(Method.java)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalStateException: java.lang.SecurityException: Incorrect signature
	at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:112)
	... 27 more
Caused by: java.lang.SecurityException: Incorrect signature
	at org.apache.harmony.security.utils.JarUtils.verifySignature(JarUtils.java:225)
	at java.util.jar.JarVerifier.verifyCertificate(JarVerifier.java:294)
	at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:268)
	at java.util.jar.JarFile.getInputStream(JarFile.java:380)
	at libcore.net.url.JarURLConnectionImpl.getInputStream(JarURLConnectionImpl.java:222)
	at java.net.URL.openStream(URL.java:470)
	at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:444)
	at org.jivesoftware.smack.util.FileUtils.getStreamForUrl(FileUtils.java:54)
	at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:109)
	... 27 more

Checking the project dependencies everything seems to be fine:

|    +--- org.igniterealtime.smack:smack-android:4.1.6
|    |    +--- org.igniterealtime.smack:smack-core:4.1.6
|    |    |    \--- org.jxmpp:jxmpp-core:0.4.2
|    |    |         \--- org.jxmpp:jxmpp-util-cache:0.4.2
|    |    +--- org.igniterealtime.smack:smack-im:4.1.6
|    |    |    \--- org.igniterealtime.smack:smack-core:4.1.6 (*)
|    |    +--- org.igniterealtime.smack:smack-resolver-minidns:4.1.6
|    |    |    +--- org.igniterealtime.smack:smack-core:4.1.6 (*)
|    |    |    +--- de.measite.minidns:minidns:[0.1,0.2) -> 0.1.7
|    |    |    \--- org.jxmpp:jxmpp-util-cache:0.4.2
|    |    \--- org.igniterealtime.smack:smack-sasl-provided:4.1.6
|    |         \--- org.igniterealtime.smack:smack-core:4.1.6 (*)
|    +--- org.igniterealtime.smack:smack-tcp:4.1.6
|    |    \--- org.igniterealtime.smack:smack-core:4.1.6 (*)
|    \--- org.igniterealtime.smack:smack-android-extensions:4.1.6
|         +--- org.igniterealtime.smack:smack-android:4.1.6 (*)
|         \--- org.igniterealtime.smack:smack-extensions:4.1.6
|              +--- org.igniterealtime.smack:smack-core:4.1.6 (*)
|              \--- org.igniterealtime.smack:smack-im:4.1.6 (*)

I have the theory that maybe it’s related with an embedded version of the library in some Android devices, but of course it doesn’t make much sense.
This developer seems to have the same issue, but I don’t think his solution would work for me, since the app is working fine for most of the users.

Do you have any idea of what could be happening here?

Thank you very much in advance.

Stacktrace #1 shows

Caused by: java.lang.IllegalArgumentException: is == null
	at org.kxml2.io.KXmlParser.setInput(KXmlParser.java:1625)
	at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:155)

Stacktrace #2 looks incomplete

Stacktrace #3 shows

Caused by: java.lang.SecurityException: Incorrect signature
	at org.apache.harmony.security.utils.JarUtils.verifySignature(JarUtils.java:225)

#1 actually could be cause the Smack’s resource files are lost somewhere, cause is to be null. Which execution environment are we talking about here?

Hello Flow, thanks for the fast response

About StackTrace #2, I don’t think it is incomplete, it’s showing a NoClassDefFoundError, so it’s not finding SmackInitialization class. Maybe is similar to #1? because it doesn’t find the config file? But I don’t understand how it happens only to a set of users.

About execution environment: it’s an Android application with a minApiLevel 16 and target 26. But the crashes are happening in different devices and OS versions.