简体   繁体   中英

Exception in thread “main” java.lang.NoSuchFieldError: ifpossible

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("27614215340@gcm.googleapis.com", 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();
}

It gives the following error

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)

These are the possible reasons of getting this Exception

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 . You might have got two versions of jar being used.

3 . Incomplete jar file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM