Help! I can't use smack_4_1_1 to connect

I am a new man to use this ,so I download the openfire_3_10_0.exe,and run well,

I also use spark_2_7_0.exe to communicate with my colleague,

QQ截图20150512165731.png

then ,I try to use java to connect with smack_4_1_1 ,but failed,I copy the API’s guide,but I doesn’t work.

Someone can help me to find that What’s wrong with my code??? thank you very much!!!

then I add some jars from openfire/lib

I have tried different ways to connect,now ,the exception is:

Exception in thread “main” java.lang.NoSuchMethodError: org.jxmpp.util.XmppStringUtils.generateKey(Ljava/lang/String;Ljava/lang/String; )Ljava/lang/String;

at org.jivesoftware.smack.provider.ProviderManager.getKey(ProviderManager.java:314 )

at org.jivesoftware.smack.provider.ProviderManager.removeIQProvider(ProviderManage r.java:217)

at org.jivesoftware.smack.provider.ProviderManager.addIQProvider(ProviderManager.j ava:199)

at org.jivesoftware.smack.provider.ProviderManager.addLoader(ProviderManager.java: 128)

at org.jivesoftware.smack.initializer.UrlInitializer.initialize(UrlInitializer.jav a:54)

at org.jivesoftware.smack.SmackInitialization.loadSmackClass(SmackInitialization.j ava:232)

at org.jivesoftware.smack.SmackInitialization.parseClassesToLoad(SmackInitializati on.java:193)

at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitializatio n.java:163)

at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitializatio n.java:148)

at org.jivesoftware.smack.SmackInitialization.(SmackInitialization.java:11 6)

at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96 )

at org.jivesoftware.smack.AbstractXMPPConnection.(AbstractXMPPConnection.j ava:98)

at com.hsco.main.CreateUser.main(CreateUser.java:15)

any help would be appreciated!!!

sorry ,I just add some jars not from openfire/lib,

I copy from asmack-master\lib

QQ截图20150513172834.png

Add the following jar to your libs folder.

  • jxmpp-core-0.4.1
  • jxmpp-util-cache-0.4.1
  • minidns-0.1.1
  • smack-android-4.1.0.jar
  • smack-android-extensions-4.1.0
  • smack-core-4.1.0
  • smack-extensions-4.1.0
  • smack-im-4.1.0
  • smack-tcp-4.1.0
  • smack-sasl-provided-4.1.0.jar
    I was having the same problem but after adding the above mentionend JARs, I was able to set up a connection with the server.

thank you so much!

I’m so excited ,because I can send simle message in Java.

I changed 2 jars :

  • jxmpp-core-0.4.1
  • jxmpp-util-cache-0.4.1

At first ,I used these old jars from asmack-master,maybe the main reason is here.

  • jxmpp-core-0.1.0
  • jxmpp-util-cache-0.1.0

I also add other jars that you didn’t mention ,maybe because of the smack_4_1_1.

even though the new exception is coming,I can send message to others…

thanks again!!!

1 Like

cheers