【问题标题】:HttpAsyncClient not getting multiple requestHttpAsyncClient 没有收到多个请求
【发布时间】:2012-11-27 10:24:57
【问题描述】:

我是 Zone 面板 JFrame 的构造函数。我必须从服务器获取区域列表和运营商列表。我正在使用 HttpAsyncClient 库来转发我的请求。问题是当我开始发送请求时我的 1 个列表(即区域列表)它正在工作但是当我发送请求以获取 2 个列表时它给了我

Exception in thread "AWT-EventQueue-0"    
java.lang.NoSuchMethodError:org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.  
<init>(Lorg/apache/http/impl/nio/reactor/IOReactorConfig;)at     
org.apache.http.impl.nio.client.AbstractHttpAsyncClient.<init>
(AbstractHttpAsyncClient.java:133)
at org.apache.http.impl.nio.client.DefaultHttpAsyncClient.<init>  
(DefaultHttpAsyncClient.java:64)

类似地,如果我只发送请求(运营商列表)它工作正常但是......当我发送两个请求时它不起作用......这是我的请求发件人类..... public JSONArray sendRequest(List postPairs){

try {
      //At this line code gives me exception i do't know why..?
      HttpAsyncClient httpclient = new DefaultHttpAsyncClient();
      httpclient.start();
      System.out.println(postPairs.get(0).getValue());
      HttpPost post = new   HttpPost("http://10.0.0.62:8080/IDocWS/"+postPairs.get(0).getValue());
      //HttpPost post = new HttpPost("http://www.google.com");
      Future<HttpResponse> future = httpclient.execute(post, null);
      HttpResponse resp = future.get();
      HttpEntity entity = resp.getEntity();
      JSONArray jArray = CovnertToJson(entity);
      return jArray;

【问题讨论】:

  • 你使用的是什么版本的 apache http 组件?
  • httpcomponents-asyncclient-4.0-beta3

标签: java http jsp servlets apache-httpclient-4.x


【解决方案1】:

尝试在您的项目中使用最新版本的 HttpComponents - http://hc.apache.org/downloads.cgi。构造函数

DefaultConnnectingIOReactor(IOReactorConfig) 

在 4.0 版本中不存在,只有 4.2+。 Apache HttpClient 正在尝试调用它,因此看起来 HttpClient 的版本需要 4.2+ 版本的 HttpComponents。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-07
    • 1970-01-01
    • 1970-01-01
    • 2021-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多