powered by Jive Software

NoSuchMethodError

Hi,

I have an exception that bugs me.

The code is:

GoogleTalkConnection conn = new GoogleTalkConnection();
conn.login(“skijash”, “*");
Chat chat = conn.createChat("
”);
chat.sendMessage(“poruka poslata preko smack-a”);

GoogleTalkConnection throws:

Exception in thread “main” java.lang.NoSuchMethodError: org.jivesoftware.smack.XMPPConnection.addConnectionCreationListener(Lorg/jiveso ftware/smack/ConnectionCreationListener;)V

at org.jivesoftware.smack.PrivacyListManager.<clinit>(PrivacyListManager.jav a:57)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:164)

at org.jivesoftware.smack.SmackConfiguration.parseClassToLoad(SmackConfiguration.j ava:176)

at org.jivesoftware.smack.SmackConfiguration.<clinit>(SmackConfiguration.jav a:81)

at org.jivesoftware.smack.XMPPConnection.<clinit>(XMPPConnection.java:88)

at com.vast.supercrawler.bots.bottools.Notifier.doSomething(Notifier.java:16)

at com.vast.supercrawler.bots.bottools.Notifier.main(Notifier.java:26)

Could somebody please tell me what`s the problem. I have a smack.jar library in my classpath and the version is 3.04

Nikola

Hi,

The GoogleTalkConnection class was removed in the 3.0 release of Smack. You have to setup a Google connection manually, using settings like the following:

host: talk.google.com

port: 5222

service name: gmail.com

You can use these settings to create a ConnectionConfiguration object and then pass that to the constructor of the XMPPConnection. That is all the old class was doing, so it is pretty simple to re-create it.

Chris

ConnectionConfiguration config = new ConnectionConfiguration(“talk.google.com”, 5222, “gmail.com”);

XMPPConnection conn = new XMPPConnection(config);

if(conn.isConnected())

conn.login(“skijash”, “******”);

Chat chat = conn.createChat("******");

chat.sendMessage(“poruka poslata preko smack-a”);


Same error:

Exception in thread “main” java.lang.NoSuchMethodError: org.jivesoftware.smack.XMPPConnection.addConnectionCreationListener(Lorg/jiveso ftware/smack/ConnectionCreationListener;)V

at org.jivesoftware.smack.PrivacyListManager.<clinit>(PrivacyListManager.jav a:57)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:164)

at org.jivesoftware.smack.SmackConfiguration.parseClassToLoad(SmackConfiguration.j ava:176)

at org.jivesoftware.smack.SmackConfiguration.<clinit>(SmackConfiguration.jav a:81)

at org.jivesoftware.smack.XMPPConnection.<clinit>(XMPPConnection.java:88)

at org.jivesoftware.smack.ConnectionConfiguration.<init>(ConnectionConfigura tion.java:55)

You also need to call connect() before you try to call login(), but that is not the cause of your current problem because you aren’t even getting that far. It seems to me you aren’t actually running Smack 3.x. You seem to be running Smack 2.x somehow because if you were running 3.x you would have got a NoClassDefFoundError when you referenced GoogleTalkConnection (removed in 3.0) and it would be able to find the new addConnectionCreationListener method (added in 3.0). So I think you need to check your libraries and classpath to make sure it is setup to use 3.0.4.

Chris

Damn, I did a

System.out.println(SmackConfiguration.getVersion());

and found out that there is an old smack api in one of our libraries…

Sorry to bug you