Smack API 4.0遇到错误" org / xmlpull / v1 / XmlPullParserFactory"和"无法实例化XMPPConnection"

时间:2014-06-09 08:28:20

标签: java smack

我正在通过Eclipse添加Smack API 4.0

将XMpp连接写入我的XMpp服务器
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;



public class XmppManager {

    public static final String HOST = "localhost";
    public static final int PORT = 5222;
    public static final String SERVICE = "chat";


    public static void main (String[] arg){
        ConnectionConfiguration connConfig = new ConnectionConfiguration(XmppManager.HOST, XmppManager.PORT,
                XmppManager.SERVICE);


    }


}

,但在此期间,我遇到如下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserFactory
    at org.jivesoftware.smack.SmackConfiguration.processConfigFile(SmackConfiguration.java:321)
    at org.jivesoftware.smack.SmackConfiguration.processConfigFile(SmackConfiguration.java:316)
    at org.jivesoftware.smack.SmackConfiguration.<clinit>(SmackConfiguration.java:148)
    at org.jivesoftware.smack.ConnectionConfiguration.<init>(ConnectionConfiguration.java:65)
    at Snapp.XmppManager.main(XmppManager.java:18)
Caused by: java.lang.ClassNotFoundException: org.xmlpull.v1.XmlPullParserFactory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 5 more

此外,在行“”下添加XMPPConnection无法实例化XMPPConnection“”

XMPPConnection connection = new XMPPConnection (connConfig);

Java_Eclipse通知“无法实例化XMPPConnection”错误

您之前遇到过两个问题吗?请帮我弄清楚这个问题。

感谢。

1 个答案:

答案 0 :(得分:3)

  

线程中的异常&#34; main&#34; java.lang.NoClassDefFoundError:   组织/ xmlpull / V1 / XmlPullParserFactory

您需要在类路径中使用XPP3

  

此外,在行&#34;&#34;下添加XMPPConnection无法实例化   XMPPConnection&#34;&#34;

在Smack 4中使用XMPPTCPConnection代替XMPPConnection