在DefaultHttpClient上调用execute时的NoSuchFieldError

时间:2013-06-10 19:14:36

标签: httprequest apache-httpclient-4.x apache-httpcomponents nosuchfieldexception

当我在DefaultHttpClient实例上调用execute时,我一直收到NoSuchFieldError。这些是我的代码行。

        HttpClient client = new DefaultHttpClient();        
        HttpPost post = new HttpPost("http://10.65.98.158/atlas/rest/comparablesBulk?type=permId");
        StringEntity req = new StringEntity(request.toJSONString(),ContentType.APPLICATION_JSON);
        post.setEntity(req);
        HttpResponse response = client.execute(post);//this is where the error happens

这是我得到的堆栈跟踪:

Exception in thread "main" java.lang.NoSuchFieldError: DEF_CONTENT_CHARSET
    at org.apache.http.impl.client.DefaultHttpClient.setDefaultHttpParams(DefaultHttpClient.java:175)
    at org.apache.http.impl.client.DefaultHttpClient.createHttpParams(DefaultHttpClient.java:158)
    at org.apache.http.impl.client.AbstractHttpClient.getParams(AbstractHttpClient.java:448)
    at org.apache.http.impl.client.AbstractHttpClient.createClientConnectionManager(AbstractHttpClient.java:309)
    at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:466)
    at org.apache.http.impl.client.AbstractHttpClient.createHttpContext(AbstractHttpClient.java:286)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:851)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
    at AtlasService.main(AtlasService.java:62)

0 个答案:

没有答案