【问题标题】:java.lang.NoClassDefFoundError when using twitter hosebirdjava.lang.NoClassDefFoundError 使用推特软管鸟时
【发布时间】:2014-12-18 03:48:09
【问题描述】:

我正在尝试使用 Twitter 流 API,以便我可以实时过滤一些推文并显示。 我正在尝试关注https://github.com/twitter/hbc

我不习惯使用 Maven,所以我在 http://www.java2s.com/Code/Jar/h/Downloadhbccore140jar.htm 找到了这个 jar 文件。我只是将它添加到我的构建路径并运行以下代码。

 BlockingQueue<String> queue = new LinkedBlockingQueue<String>(10000);
     StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint();

但是,我收到以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest
    at com.twitter.hbc.core.endpoint.BaseEndpoint.<init>(BaseEndpoint.java:40)
    at com.twitter.hbc.core.endpoint.DefaultStreamingEndpoint.<init>(DefaultStreamingEndpoint.java:35)
    at com.twitter.hbc.core.endpoint.StatusesFilterEndpoint.<init>(StatusesFilterEndpoint.java:34)
    at com.twitter.hbc.core.endpoint.StatusesFilterEndpoint.<init>(StatusesFilterEndpoint.java:27)
    at StreamingApi.main(StreamingApi.java:36)
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpUriRequest
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)

我什至尝试过使用 Maven 编译并将编译的类转换为 jar 文件然后使用。但是,我得到同样的错误。看起来很少有内部依赖项没有解决。

有人可以帮助我吗?提前致谢。

【问题讨论】:

    标签: twitter-streaming-api twitter-hbc


    【解决方案1】:

    您似乎缺少包含必要的 jar 文件 httpclient.jar

    Download from here

    【讨论】:

      【解决方案2】:

      很难手动找到每个jar并添加到构建路径和测试。所以,我终于学会了使用 Maven - https://github.com/twitter/hbc

      但是,Guava 库是一个旧库,并产生了一些错误。我使用来自https://code.google.com/p/guava-libraries/ 的 Guava-18.0,它工作正常。

      【讨论】:

        猜你喜欢
        • 2013-09-03
        • 1970-01-01
        • 1970-01-01
        • 2010-11-05
        • 1970-01-01
        • 2015-04-07
        • 1970-01-01
        • 1970-01-01
        • 2014-10-05
        相关资源
        最近更新 更多