Java 无法创建新的 PoolingHttpClientConnectionManager

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19641910/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 19:02:36  来源:igfitidea点击:

Failing to create new PoolingHttpClientConnectionManager

javahttpclient

提问by user2816029

My program contains the following line, and just hangs at this point, and I'm not quite sure why.

我的程序包含以下行,此时挂起,我不太确定为什么。

PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();

When debugging in Eclipse, if I try to evaluate "new PoolingHttpClientConnectionManager()" in the Display view I get these errors:

在 Eclipse 中调试时,如果我尝试在 Display 视图中评估“new PoolingHttpClientConnectionManager()”,我会收到以下错误:

java.lang.NoClassDefFoundError: org/apache/http/config/Lookup
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    ...omitted - referring to specific lines in code...
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.http.config.Lookup
    at java.net.URLClassLoader.run(Unknown Source)
    at java.net.URLClassLoader.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 10 more

I am using httpclient.jar version 4.3.1 from org.apache.httpcomponents.

我正在使用来自 org.apache.httpcomponents 的 httpclient.jar 版本 4.3.1。

Anyone else experience this problem? Any solution? Or am I doing something silly?

还有其他人遇到过这个问题吗?有什么解决办法吗?还是我在做傻事?

采纳答案by Luciano

Do you also have httpcorejar? (version 4.3 as well) I've found that class there.

你也有httpcorejar吗?(也是 4.3 版)我在那里找到了那个类。

回答by Wouter

Maybe you forgot to include/download HttpCore

也许你忘了包含/下载 HttpCore

http://hc.apache.org/downloads.cgi

http://hc.apache.org/downloads.cgi

回答by Ken Lin

The org.apache.http.config.Lookupclass is not in httpclient-4.3.1.jar. It is in httpcore-4.3.jar.

org.apache.http.config。查找类不在 httpclient-4.3.1.jar 中。它在 httpcore-4.3.jar 中。

If you are not using Maven, to understand the httpclient dependencies, see http://hc.apache.org/httpcomponents-client-4.3.x/httpclient/dependencies.html

如果您没有使用 Maven,要了解 httpclient 依赖项,请参阅http://hc.apache.org/httpcomponents-client-4.3.x/httpclient/dependencies.html