java.lang.NoSuchMethodError:org.apache.http.protocol.BasicHttpContext:method< init>()V not found
-
06-07-2019 - |
質問
こんにちは、小さな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と競合しているように見えますが、私は理解できませんでした。手がかりはありがたいです。
解決
BasicHttpContext
の古いバージョンと新しいバージョンのjarファイルがあるようです。直接の競合があった場合、 ClassNotFoundException
を受け取ります。 ClassLoadersは通常、この種のことについてのジャークです。この場合、クラスは存在しますが、別のライブラリ( Context
を呼び出しているのはhttpclientであると思われます)がコンパイルされたメソッドはありません。
所属していません StackOverflow