9

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

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 与我的应用程序中的其他一些 jar 发生冲突,但我无法弄清楚。任何线索将不胜感激。

4

1 回答 1

10

看起来您有一个带有旧/新版本的 .jar 文件BasicHttpContext。如果存在直接冲突,您将收到一个ClassNotFoundException. 类加载器通常对这种事情很敏感。在这种情况下,该类存在但是没有另一个库(我相信它是调用 的 httpclient Context)被编译的方法。

于 2009-10-24T05:28:48.690 回答