本文介绍了线程"main"中的异常java.lang.NoSuchFieldError:如果可能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Smack库建立XMPP连接.使用版本4.2.0-beta2(smack-core)和4.1.8(smack-tcp)

I am trying to establish a XMPP connection using the Smack library. Using the version 4.2.0-beta2(smack-core) and 4.1.8(smack-tcp)

public void gcmConnect()
{
    try{

    XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder().setHost(GCM_SERVER)
            .setPort(GCM_PORT).setUsernameAndPassword("[email protected]", API_KEY).build();

    XMPPTCPConnection connection = new XMPPTCPConnection(config);
    connection.connect();

    System.out.println("Connected");

    }
    catch(XMPPException ex)
    {
        ex.printStackTrace();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
}

public static void main(String[] args) {
    XMPPConnectionTest obj = new XMPPConnectionTest();
    obj.gcmConnect();
}

出现以下错误

Exception in thread "main" java.lang.NoSuchFieldError: ifpossible
at org.jivesoftware.smack.ConnectionConfiguration$Builder.<init>(ConnectionConfiguration.java:438)
at org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration$Builder.<init>(XMPPTCPConnectionConfiguration.java:91)
at org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration$Builder.<init>(XMPPTCPConnectionConfiguration.java:87)
at org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration.builder(XMPPTCPConnectionConfiguration.java:80)
at com.inn.foresight.gcm.XMPPConnectionTest.gcmConnect(XMPPConnectionTest.java:32)
at com.inn.foresight.gcm.XMPPConnectionTest.main(XMPPConnectionTest.java:53)

推荐答案

这些是导致此 Exception

1 .您可能使用库的一个版本进行编译,但在运行时使用另一版本.您必须验证您的 classpath 包含指定库的正确版本.

1. You probably compile using one version of a library, but use another version at run-time . You must verify that your classpath contains the proper version of the specified library.

2 .您可能已经使用了两个版本的 jar .

2. You might have got two versions of jar being used.

3 .jar文件不完整

这篇关于线程"main"中的异常java.lang.NoSuchFieldError:如果可能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 08:23