Paradox
Paradox

Reputation: 367

I'm having trouble creating XMPP client using smack 4.2 Openfire

I want to create a simple XMPP client that connects to my Openfire server. I got the following problem when I'm running the code.

code:

public void setConnection() {

    try {

        XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
        config.setUsernameAndPassword(userName,password);
        config.setResource("temp");
        config.setXmppDomain("undercrroft");

        AbstractXMPPConnection connection = new XMPPTCPConnection(config.build());
        connection.connect();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (SmackException e) {
        e.printStackTrace();
    } catch (XMPPException e) {
        e.printStackTrace();
    }

Error:

Information:java: Errors occurred while compiling module 'Messenger'
Information:javac 1.8.0_121 was used to compile java sources
Information:16/4/17 1:52 AM - Compilation completed with 2 errors and 0 warnings in 871ms
/home/paradox/Desktop/Project/Messenger/src/ConnectServer.java
Error:(28, 19) java: cannot access org.jxmpp.stringprep.XmppStringprepException
                class file for org.jxmpp.stringprep.XmppStringprepException not found
Error:(29, 19) java: cannot access org.jxmpp.jid.DomainBareJid
                class file for org.jxmpp.jid.DomainBareJid not found

These are my imports:

import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;

Thanks.

Upvotes: 1

Views: 1890

Answers (2)

Paradox
Paradox

Reputation: 367

Update the Library..!

Those two libraries are defined in the newer library.

Upvotes: 0

Guus
Guus

Reputation: 3006

You are missing the required jxmpp libraries. Please have a look at the Smack documentation, which lists all dependencies: https://github.com/igniterealtime/Smack/wiki/Smack-4.2-Readme-and-Upgrade-Guide#using-eclipses-android-development-tools-adt-ant-based-build

Note that using a dependency manager (Gradle, Maven, Ivy) is highly recommended to prevent issues like this.

Upvotes: 2

Related Questions