AnsweredAssumed Answered

xmpp connection error on smack 4.1.1

Question asked by ximo on Dec 10, 2016

i'v test connection between eclipse with Smack 4.1.1  and openfire4.0.4  in localhost, but got some error. please help me

Thank you in advance.

 

12-11 07:34:29.171: E/AndroidRuntime(17961): FATAL EXCEPTION: AsyncTask #4

12-11 07:34:29.171: E/AndroidRuntime(17961): Process: com.wqx.im, PID: 17961

12-11 07:34:29.171: E/AndroidRuntime(17961): java.lang.RuntimeException: An error occured while executing doInBackground()

12-11 07:34:29.171: E/AndroidRuntime(17961): at android.os.AsyncTask$3.done(AsyncTask.java:304)

12-11 07:34:29.171: E/AndroidRuntime(17961): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)

12-11 07:34:29.171: E/AndroidRuntime(17961): at java.util.concurrent.FutureTask.setException(FutureTask.java:222)

12-11 07:34:29.171: E/AndroidRuntime(17961): at java.util.concurrent.FutureTask.run(FutureTask.java:242)

12-11 07:34:29.171: E/AndroidRuntime(17961): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)

12-11 07:34:29.171: E/AndroidRuntime(17961): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

12-11 07:34:29.171: E/AndroidRuntime(17961): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

12-11 07:34:29.171: E/AndroidRuntime(17961): at java.lang.Thread.run(Thread.java:818)

12-11 07:34:29.171: E/AndroidRuntime(17961): Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jxmpp/util/XmppStringUtils;

12-11 07:34:29.171: E/AndroidRuntime(17961): at org.jivesoftware.smack.provider.ProviderManager.getKey(ProviderManager.java:314 )

12-11 07:34:29.171: E/AndroidRuntime(17961): at org.jivesoftware.smack.provider.ProviderManager.addStreamFeatureProvider(Provid erManager.java:304)

12-11 07:34:29.171: E/AndroidRuntime(17961): at org.jivesoftware.smack.provider.ProviderManager.addLoader(ProviderManager.java: 140)

12-11 07:34:29.171: E/AndroidRuntime(17961): at org.jivesoftware.smack.initializer.UrlInitializer.initialize(UrlInitializer.jav a:54)

12-11 07:34:29.171: E/AndroidRuntime(17961): at org.jivesoftware.smack.SmackInitialization.loadSmackClass(SmackInitialization.j ava:232)

12-11 07:34:29.171: E/AndroidRuntime(17961): at org.jivesoftware.smack.SmackInitialization.parseClassesToLoad(SmackInitializati on.java:193)

12-11 07:34:29.171: E/AndroidRuntime(17961): at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitializatio n.java:163)

12-11 07:34:29.171: E/AndroidRuntime(17961): at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitializatio n.java:148)

12-11 07:34:29.171: E/AndroidRuntime(17961): at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:11 6)

12-11 07:34:29.171: E/AndroidRuntime(17961): at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96 )

12-11 07:34:29.171: E/AndroidRuntime(17961): at org.jivesoftware.smack.ConnectionConfiguration.<clinit>(ConnectionConfiguration .java:38)

12-11 07:34:29.171: E/AndroidRuntime(17961): at com.wqx.im.utils.ConnectionManager.openConnection(ConnectionManager.java:25)

12-11 07:34:29.171: E/AndroidRuntime(17961): at com.wqx.im.utils.ConnectionManager.getConnection(ConnectionManager.java:18)

12-11 07:34:29.171: E/AndroidRuntime(17961): at com.wqx.im.activity.LoginActivity$LoginTask.doInBackground(LoginActivity.java:5 4)

12-11 07:34:29.171: E/AndroidRuntime(17961): at com.wqx.im.activity.LoginActivity$LoginTask.doInBackground(LoginActivity.java:1 )

12-11 07:34:29.171: E/AndroidRuntime(17961): at android.os.AsyncTask$2.call(AsyncTask.java:292)

12-11 07:34:29.171: E/AndroidRuntime(17961): at java.util.concurrent.FutureTask.run(FutureTask.java:237)

12-11 07:34:29.171: E/AndroidRuntime(17961): ... 4 more

12-11 07:34:29.171: E/AndroidRuntime(17961): Caused by: java.lang.ClassNotFoundException: Didn't find class "org.jxmpp.util.XmppStringUtils" on path: DexPathList[[zip file "/data/app/com.wqx.im-2/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]

12-11 07:34:29.171: E/AndroidRuntime(17961): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

12-11 07:34:29.171: E/AndroidRuntime(17961): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)

12-11 07:34:29.171: E/AndroidRuntime(17961): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)

12-11 07:34:29.171: E/AndroidRuntime(17961): ... 21 more

12-11 07:34:29.171: E/AndroidRuntime(17961): Suppressed: java.lang.ClassNotFoundException: org.jxmpp.util.XmppStringUtils

12-11 07:34:29.171: E/AndroidRuntime(17961): at java.lang.Class.classForName(Native Method)

12-11 07:34:29.171: E/AndroidRuntime(17961): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)

12-11 07:34:29.171: E/AndroidRuntime(17961): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)

12-11 07:34:29.171: E/AndroidRuntime(17961): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)

12-11 07:34:29.171: E/AndroidRuntime(17961): ... 22 more

12-11 07:34:29.171: E/AndroidRuntime(17961): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

 

 

this is my code

import org.jivesoftware.smack.AbstractXMPPConnection;

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;

import org.jivesoftware.smack.tcp.XMPPTCPConnection;

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration.Builder;

 

 

public class ConnectionManager {

  private static AbstractXMPPConnection connection = null;

 

 

  private static String host = "192.168.31.91";

  private static int port = 5222;

  private static String serviceName ="192.168.31.91";

 

  public static AbstractXMPPConnection getConnection(){

  if(connection == null){

  openConnection();

  }

  return connection;

  }

 

 

  private static void openConnection() {

  // TODO Auto-generated method stub

  Builder builder = XMPPTCPConnectionConfiguration.builder();

  builder.setHost(host);

  builder.setPort(port);

  builder.setServiceName(serviceName);

  builder.setSecurityMode(SecurityMode.disabled);

 

  connection = new XMPPTCPConnection(builder.build());

 

  try{

  connection.connect();

  }catch(Exception e){

  e.printStackTrace();

  }

  }

  public static void release(){

  if(connection != null){

  connection.disconnect();

  }

  }

}

Outcomes