Smack 抛出 java.lang.ClassNotFoundException: org.apache.http.conn.ssl.StrictHostnameVerifier

Posted

技术标签:

【中文标题】Smack 抛出 java.lang.ClassNotFoundException: org.apache.http.conn.ssl.StrictHostnameVerifier【英文标题】:Smack throws java.lang.ClassNotFoundException: org.apache.http.conn.ssl.StrictHostnameVerifier 【发布时间】:2014-10-15 05:07:57 【问题描述】:

我已按照链接https://developer.android.com/google/gcm/ccs.html#implement上的教程进行操作。

我正在使用 Smack 4.0.4。

我已经为“connect”方法创建了一个端点,并将这个类部署在谷歌应用引擎上。

但是,当我从我的 android 移动客户端应用程序调用“连接”时,我得到如下所示的异常。

是否需要下载包含 org/apache/http/conn/ssl/StrictHostnameVerifier 的 jar 并添加到 Android Studio 中的依赖项?

感谢任何有用的评论!

java.lang.NoClassDefFoundError: org/apache/http/conn/ssl/StrictHostnameVerifier
at org.jivesoftware.smack.android.AndroidSmackInitializer.initialize(AndroidSmackInitializer.java:29)
at org.jivesoftware.smack.SmackConfiguration.loadSmackClass(SmackConfiguration.java:472)
at org.jivesoftware.smack.SmackConfiguration.parseClassesToLoad(SmackConfiguration.java:430)
at org.jivesoftware.smack.SmackConfiguration.processConfigFile(SmackConfiguration.java:400)
at org.jivesoftware.smack.SmackConfiguration.processConfigFile(SmackConfiguration.java:385)
at org.jivesoftware.smack.SmackConfiguration.<clinit>(SmackConfiguration.java:161)
at org.jivesoftware.smack.ConnectionConfiguration.<init>(ConnectionConfiguration.java:69)
at com.example.mymodule.XMPPServer.SmackCcsClientEndpoint.connect(SmackCcsClientEndpoint.java:267)
at com.example.mymodule.XMPPServer.SmackCcsClientEndpoint.getInstance(SmackCcsClientEndpoint.java:73)
at com.example.mymodule.connectionServlet.CcsServlet.init(CcsServlet.java:24)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:490)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.ssl.StrictHostnameVerifier
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:216)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 47 more
Caused by:

java.lang.ClassNotFoundException: org.apache.http.conn.ssl.StrictHostnameVerifier
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:216)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.jivesoftware.smack.android.AndroidSmackInitializer.initialize(AndroidSmackInitializer.java:29)
at org.jivesoftware.smack.SmackConfiguration.loadSmackClass(SmackConfiguration.java:472)
at org.jivesoftware.smack.SmackConfiguration.parseClassesToLoad(SmackConfiguration.java:430)
at org.jivesoftware.smack.SmackConfiguration.processConfigFile(SmackConfiguration.java:400)
at org.jivesoftware.smack.SmackConfiguration.processConfigFile(SmackConfiguration.java:385)
at org.jivesoftware.smack.SmackConfiguration.<clinit>(SmackConfiguration.java:161)
at org.jivesoftware.smack.ConnectionConfiguration.<init>(ConnectionConfiguration.java:69)
at com.example.mymodule.XMPPServer.SmackCcsClientEndpoint.connect(SmackCcsClientEndpoint.java:267)
at com.example.mymodule.XMPPServer.SmackCcsClientEndpoint.getInstance(SmackCcsClientEndpoint.java:73)
at com.example.mymodule.connectionServlet.CcsServlet.init(CcsServlet.java:24)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:490)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

【问题讨论】:

【参考方案1】:

将 jar 添加到依赖项中,效果很好

【讨论】:

以上是关于Smack 抛出 java.lang.ClassNotFoundException: org.apache.http.conn.ssl.StrictHostnameVerifier的主要内容,如果未能解决你的问题,请参考以下文章

Smack 抛出 java.lang.ClassNotFoundException: org.apache.http.conn.ssl.StrictHostnameVerifier

Smack API 抛出 item-not-found(404) 异常

如何在安卓上使用 Smack

如何在使用 Smack 发送聊天时检测错误

Smack 4.1.8 解析失败:Lorg/jivesoftware/smack/tcp/XMPPTCPConnectionConfiguration;

Smack 异常 - 由我的 Java 安装或 Smack 引起