获取" java.lang.NoClassDefFoundError:org / apache / http / nio / reactor / IOReactorException"

时间:2014-11-03 12:59:29

标签: java exception jar unirest

我试图使用Mashape api,我已将以下库(jars)unirest,httpasyncclient,httpclient,httpmime,org.json,commons-longging,httpcore添加到我的项目中。

我试图跑...

HttpResponse<JsonNode> response = Unirest.post("https://life-left.p.mashape.com/time-left")
.header("X-Mashape-Key", "1NZITOdDGqmshKRAEdDbX0tp0WV2p1RR5SSjsnQYQIVwrANkhC")
.header("Content-Type", "application/x-www-form-urlencoded")
.field("birth", "22 April 1977")
.field("gender", "female")
.asJson();

但我得到了这个例外......

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/nio/reactor/IOReactorException
at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:154)
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:131)
at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
at test.Test.main(Test.java:24)
Caused by: java.lang.ClassNotFoundException: org.apache.http.nio.reactor.IOReactorException
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 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

我试过谷歌搜索但我无法找出问题所在。

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:8)

我有同样的问题但在我的项目pom.xml文件中添加以下依赖项后解决了

def anti_vowel(text):
    for i in range(0, len(text)):
        if text[i] in "aeiouAEIOU":
            text = text.replace(text[i], "") 

    return text