powered by Jive Software

Problems in using Smack

Hi,guys.

I am a newer in openfire and smack.

I just code a simply program to test my openfire server.

but there are some errors.

And I find that the Smack-docs is not the latest one ,the examples in Smack-doc not suit the Smack 4.0.

Where can i find the latest docs ?

I am newer here ,any sugestions can help ,thank u !

my code:

import java.io.IOException;
import org.jivesoftware.smack.;
import org.jivesoftware.smack.packet.
;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;

public class IMClient{
public static void main(String[] args) throws SmackException, IOException, XMPPException{
XMPPConnection con = new XMPPTCPConnection(“10.199.36.124”);
con.connect();
con.login(“zhuoge”, “login137235”);
ChatManager chatmanager = ChatManager.getInstanceFor(con);
Chat newChat = chatmanager.createChat("wxf@10.199.36.124", new MessageListener() {
public void processMessage(Chat chat, Message message) {
System.out.println("Received message: " + message);
}
});
newChat.sendMessage(“Howdy!”);

}
}

errors:

Exception in thread “main” java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserFactory

at org.jivesoftware.smack.SmackConfiguration.processConfigFile(SmackConfiguration. java:321)

at org.jivesoftware.smack.SmackConfiguration.processConfigFile(SmackConfiguration. java:316)

at org.jivesoftware.smack.SmackConfiguration.(SmackConfiguration.java:148)

at org.jivesoftware.smack.XMPPConnection.(XMPPConnection.java:113)

at IMClient.main(IMClient.java:9)

Caused by: java.lang.ClassNotFoundException: org.xmlpull.v1.XmlPullParserFactory

at java.net.URLClassLoader$1.run(Unknown Source)

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

… 5 more

A search for the exception you are seeing yields: https://community.igniterealtime.org/thread/52948

The javadoc of Smack is not complete,and not the latest.

For example,class AbstractXMPPXConnection is in the SDK.

However,i cannot find it in javadoc .

There are many errors like this……

The javadoc of Smack
Please specifiy where you are looking up the javadoc, as there are multiple instances of Smacks javadoc. For example

https://www.igniterealtime.org/builds/smack/docs/latest/javadoc/

http://www.igniterealtime.org/builds/smack/dailybuilds/javadoc/

For example,class AbstractXMPPXConnection is in the SDK.

However,i cannot find it in javadoc .

That’s because it’s not part of the public API.

Thank you .

I have downloaded the lastest offical release:smack_4_0_0.

But the docs in folder: smack_4_4_0>>releasedocs>>documentation cannot suit the sdk .the docs here is very

important to newer. When i follow the examples in the docs step by step,I got many errors.

eg: in file Overview,there is a guide for sending a text message to a user :

Connection connection = new XMPPConnection(“jabber.org”);

connecttion.connect();

There is not a Connection class in the SDK .

Is there something wrong with me ?

or the docs is not the lastest ?

Thank u again !

1 Like