java.lang.NoSuchMethodError:org.apache.http.protocol.BasicHttpContext:method< init>()找不到V [英] java.lang.NoSuchMethodError: org.apache.http.protocol.BasicHttpContext: method <init>()V not found

查看:953
本文介绍了java.lang.NoSuchMethodError:org.apache.http.protocol.BasicHttpContext:method< init>()找不到V的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正试图建立一个小型的webapp,但我遇到了错误。下面是我的代码

Hi I am trying to put up a small webapp but I am getting above error. Below is my code

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("SomeURL"); // Using a URL local to my machine
// after setting nameValuePair and setting it on httppost
httppost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));

// This is where I am getting the above mentioned exception
HttpResponse response = httpclient.execute(httppost);

我使用的是httpclient-4.0-beta2.jar和httpcore-4.0.1.jar。看起来BasicHttpContext与我的应用程序中的其他一些罐子发生了冲突,但我无法弄明白。任何线索将不胜感激。

I am using httpclient-4.0-beta2.jar and httpcore-4.0.1.jar. It looks like BasicHttpContext is getting conflicted with some other jars in my app, but I couldn't figure it out. Any clue will be appreciated.

推荐答案

看起来你有一个带有旧版本/更新版本<$ c $的jar文件C> BasicHttpContext 。如果存在直接冲突,则会收到 ClassNotFoundException 。 ClassLoader通常是关于这种事情的混蛋。在这种情况下,该类存在但没有另一个库(我相信它的httpclient调用 Context )编译的方法。

It looks like you have a jar file with an old/newer version of BasicHttpContext. If there was a direct conflict, you'd receive a ClassNotFoundException. ClassLoaders are typically jerks about this kind of thing. In this case, the class exists however does not have the method that another library (I believe it's httpclient that's invoking the Context) was compiled against.

这篇关于java.lang.NoSuchMethodError:org.apache.http.protocol.BasicHttpContext:method&lt; init&gt;()找不到V的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆