java ClassNotFoundException HttpRequestInterceptor
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10422830/
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
ClassNotFoundException HttpRequestInterceptor
提问by myro
I am getting this weird exception on this line:
我在这一行遇到了这个奇怪的异常:
HttpSolrServer server = new HttpSolrServer("http://localhost:8080/solr/");
Stack trace:
堆栈跟踪:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/HttpRequestInterceptor
at com.polgar.dipl.index.SolrIndex.init(SolrIndex.java:36)
at com.polgar.dipl.index.SolrIndex.getInstance(SolrIndex.java:30)
at com.polgar.dipl.main.ArticleIndexer.main(ArticleIndexer.java:44)
Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpRequestInterceptor
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)
... 3 more
回答by ThoughtfulHacking
Getting the same problem. We both must be playing with Solr 3.6
遇到同样的问题。我们都必须在玩 Solr 3.6
I had to download the HttpClient jars from the HttpComponents project. They didn't seem to be included with Solr 3.6
我必须从 HttpComponents 项目下载 HttpClient jar。他们似乎没有包含在 Solr 3.6 中
http://hc.apache.org/downloads.cgi
http://hc.apache.org/downloads.cgi
3.6 Has a new version of the client that uses the new HttpComponents (4.0) stuff, not the old HttpClient (3.1) stuff. The old 3.1 jar is there, but not the new one.
3.6 有一个新版本的客户端,它使用新的 HttpComponents (4.0) 内容,而不是旧的 HttpClient (3.1) 内容。旧的 3.1 jar 在那里,但不是新的。
Once I copied the jars over, it worked.
一旦我复制了罐子,它就起作用了。
I copied the following (not all may be needed).
我复制了以下内容(可能不需要全部)。
httpclient-4.1.3.jar
httpclient-cache-4.1.3.jar
httpcore-4.1.4.jar
httpmime-4.1.3.jar
works for me, now.
现在对我有用。
回答by Michael Murphree
If you are using Maven to include SOLRJ, you'll also want the following phrases in your POM:
如果您使用 Maven 来包含 SOLRJ,您还需要在 POM 中包含以下短语:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.2.1</version>
</dependency>
回答by Francis Upton IV
Looks like you are missing the HttpClient Jar file in your runtime classpath.
看起来您的运行时类路径中缺少 HttpClient Jar 文件。
回答by Mayank Vaidya
I was also facing this issue. To resolve this, I have done following:
我也面临这个问题。为了解决这个问题,我做了以下工作:
- Checked the versions available of http components in your "~.m2\repository\org\apache\httpcomponents" directory
- Based on that add following entries in your pom.xml file and rebuild your project by running
mvn clean install
andmvn eclipse:eclipse
command one by one. (If you are behind the proxy, make sure you have provided essential configuration in your settings.xml file)
- 检查“~.m2\repository\org\apache\httpcomponents”目录中http组件的可用版本
- 基于此,在您的 pom.xml 文件中添加以下条目,并通过运行
mvn clean install
和mvn eclipse:eclipse
命令一一重建您的项目。(如果您在代理后面,请确保您在 settings.xml 文件中提供了必要的配置)
This should resolve the problem, It did for me. :)
这应该可以解决问题,它对我有用。:)
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.2.3</version>
</dependency>