powered by Jive Software

Smack is too unstable since 4.x, java.lang.ExceptionInInitializerError


#1

Smack is a famous xmpp client lib before version 4, and is still stable and easy to use.

However, it tends to be too unstable since 4.x. The code is not compatible with the old, the build scripts is wired to build, and always get all kinds of error. The forum is full of many problems.

Today, I got the such problem.

Exception in thread “main” java.lang.ExceptionInInitializerError
at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:97)
at org.jivesoftware.smack.ConnectionConfiguration.(ConnectionConfiguration.java:57)
at net.xcrane.xmpp.tools.app.main(app.java:23)
Caused by: java.lang.IllegalStateException: java.lang.RuntimeException: Stub!
at org.jivesoftware.smack.SmackInitialization.(SmackInitialization.java:123)
… 3 more
Caused by: java.lang.RuntimeException: Stub!
at org.apache.http.conn.ssl.AbstractVerifier.(AbstractVerifier.java:5)
at org.apache.http.conn.ssl.StrictHostnameVerifier.(StrictHostnameVerifier.java:5)
at org.jivesoftware.smack.android.AndroidSmackInitializer.initialize(AndroidSmackInitializer.java:34)
at org.jivesoftware.smack.SmackInitialization.loadSmackClass(SmackInitialization.java:238)
at org.jivesoftware.smack.SmackInitialization.parseClassesToLoad(SmackInitialization.java:199)
at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:169)
at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:154)
at org.jivesoftware.smack.SmackInitialization.(SmackInitialization.java:120)
… 3 more

my code is as below:

	SmackConfiguration.addDisabledSmackClass("org.jivesoftware.smack.util.dns.minidns.MiniDnsResolver");
	XMPPTCPConnectionConfiguration config = null;
	AbstractXMPPConnection xmppCnn = null;
		
	try {
		
		config = XMPPTCPConnectionConfiguration.builder()
				.setDebuggerEnabled(true)
				.setXmppDomain("sun")
				.setHost("localhost")
				.setSecurityMode(XMPPTCPConnectionConfiguration.SecurityMode.disabled)
				.setPort(5222)
				.setDnssecMode(DnssecMode.disabled)
				.build();
		
		xmppCnn = new XMPPTCPConnection(config);
		xmppCnn.connect();
		
		xmppCnn.login("snowing", "snowing");
	} catch (Exception e1) {
		e1.printStackTrace();	
	}

Smack version: 4.2.1