java smack openfire初始化失败
最近在学习如何实用openfire来做一个消息推送服务器。学习smack的时候按照官方文档写了一个test。
但是启动的时候就报错。ExceptionInInitializerError。
官方文档上并没有找到解决方法。
以下是异常:
java.lang.ExceptionInInitializerError
at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96)
at org.jivesoftware.smack.AbstractXMPPConnection.<clinit>(AbstractXMPPConnection.java:97)
at AccountManagerTest.login(AccountManagerTest.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.IllegalStateException: org.xmlpull.v1.XmlPullParserException: could not load any factory class (even small or full default implementation); nested exception is:
org.kxml2.io.XmlReader
at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:119)
... 29 more
Caused by: org.xmlpull.v1.XmlPullParserException: could not load any factory class (even small or full default implementation); nested exception is:
org.kxml2.io.XmlReader
at org.xmlpull.v1.XmlPullParserFactory.newInstance(XmlPullParserFactory.java:225)
at org.xmlpull.v1.XmlPullParserFactory.newInstance(XmlPullParserFactory.java:76)
at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:153)
at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:148)
at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:116)
... 29 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据官方的例子写的测试通过
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
// .setUsernameAndPassword(username, password)
.setServiceName(serviceName)
.setHost(host)
.setPort(5222)
.setDebuggerEnabled(true)
.setSecurityMode(SecurityMode.disabled)
.build();
// AbstractXMPPConnection conn2 = new XMPPTCPConnection(username,password,"127.0.0.1");
AbstractXMPPConnection conn2 = new XMPPTCPConnection(config);
try {
// SASLAuthentication.registerSASLMechanism(new SASLPlainMechanism());
conn2.connect();
// conn2.login();
conn2.login(username, password,resource);