Error while trying to connect smack to openfire

Asked

Viewed 179 times

0

I am trying to perform a simple example to connect to an openfire server using the smack library 4.0.6 and have the following code:

ConnectionConfiguration configuration= new ConnectionConfiguration(ADDRESS, 5222);
configuration.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
SSLContext sc = null;
try {
    sc = SSLContext.getInstance("TLS");
    sc.init(null, new TrustManager[] { new AcceptAllTrustManager() }, new SecureRandom());
} catch (Exception e1) {
    e1.printStackTrace();
}
configuration.setCustomSSLContext(sc);
XMPPConnection connection = new XMPPTCPConnection(configuration);
try {
   connection.connect();
} catch (Exception e) {
   e.printStackTrace();
   return;
}

The part of the TSL protocol it manages to perform completely, however when I try to connect it returns the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/jivesoftware/smackx/disco/ServiceDiscoveryManager
at org.jivesoftware.smackx.hoxt.HOXTManager$1.connectionCreated(HOXTManager.java:43)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.initConnection(XMPPTCPConnection.java:490)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPConnection.java:440)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:811)
at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:396)
at Main.main(Main.java:56)

Which leads me to believe that what’s missing is a library that has the class definition ServiceDiscoveryManager. Meanwhile I’ve imported all the libraries that it is supplied by Ignite and it still doesn’t work.

What dependency is lacking for him?

  • Felipe, how are you building your application? Is it a web application? Does it use a tool that manages dependencies or is downloading jars and putting in the folder libs?

  • I’m putting it in the libs folder, but I’m not using any tool that manages dependencies. When I try to build the application it gives this error. And yes, it is a web application.

  • My guess is that jar is not going to the classpath of the web application. Does this code run in a web module or ejb? If it’s on the web, you’re deploying a .war with the jar in the folder WEB-INF/libs, can see this both in the project and in the file . War)?

  • Ah, I misexpressed myself, it’s actually just a desktop application that uses the web. It’s a very simple example, actually.

  • Running straight through the IDE? You’ve set the project classpath to include jars?

  • That’s right from the IDE. I did. As I said, it includes everyone he requested. ://

  • 1

    Felipe, sorry to keep you waiting. Did you import version 4.0.6 of the smack, did you see if there was a jar of "Xtensions" in the zip? I looked at the repository and really this class is in the project "smack-Extensions". My suggestion would be to clone the repository, but just take the Extensions project or take the source and create a "brother" project and make the dependency between them and run to see.

  • @Wakim, was exactly that, I had not realized that had not mattered to extensions, can add as a response.

Show 3 more comments

1 answer

1


The class org.jivesoftware.smackx.disco.ServiceDiscoveryManager belongs to the module of Extensions smack.

Just include the jar of smack-Extensions by the jar of smack in your project.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.