2

当我在 DefaultHttpClient 实例上调用执行时,我不断收到 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)
4

0 回答 0