Java:java.lang.NoClassDefFoundError:org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager

时间:2021-05-04 15:38:00

I created a webservice using servlet and Tomcat 6.0. I created a java project in eclipse to call that webservice using HTTP.
I added the following jar files
1. httpcore-4.0
2. httpclient-4.0
but while running the project im getting the following error.

我使用servlet和Tomcat 6.0创建了一个web服务。我在eclipse中创建了一个java项目,使用HTTP调用该webservice。我添加了以下jar文件1. httpcore-4.0 2. httpclient-4.0但是在运行项目时我得到以下错误。

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager.<init>(ThreadSafeClientConnManager.java:75)
at WSCall.HttpUtilities.GetServerResponse(HttpUtilities.java:52)
at WSCall.ServiceCall.main(ServiceCall.java:16)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.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    

Please help me to find the solution.

请帮我找到解决方案。

3 个解决方案

#1


0  

You still have to add common-logging dependency under your classpath. However, you may continue encounter other simaliar Exceptions due to lack other dependency. I suggest you use maven to manage the dependency so that you don't have to mannualy add dependencies to your classpath.

您仍然必须在类路径下添加common-logging依赖项。但是,由于缺乏其他依赖性,您可能会继续遇到其他simaliar异常。我建议您使用maven来管理依赖项,这样您就不必手动将依赖项添加到类路径中。

#2


0  

It seems your project doesn't contain the Apache Commons Logging library. Adding it to your classpath should do the trick.

您的项目似乎不包含Apache Commons Logging库。将它添加到类路径应该可以解决问题。

#3


0  

This is caused by the missing of commons-logging.jar.To fix it, download the commons logging library and add it to your project.

这是由于缺少commons-logging.jar引起的。要修复它,请下载commons日志库并将其添加到项目中。

#1


0  

You still have to add common-logging dependency under your classpath. However, you may continue encounter other simaliar Exceptions due to lack other dependency. I suggest you use maven to manage the dependency so that you don't have to mannualy add dependencies to your classpath.

您仍然必须在类路径下添加common-logging依赖项。但是,由于缺乏其他依赖性,您可能会继续遇到其他simaliar异常。我建议您使用maven来管理依赖项,这样您就不必手动将依赖项添加到类路径中。

#2


0  

It seems your project doesn't contain the Apache Commons Logging library. Adding it to your classpath should do the trick.

您的项目似乎不包含Apache Commons Logging库。将它添加到类路径应该可以解决问题。

#3


0  

This is caused by the missing of commons-logging.jar.To fix it, download the commons logging library and add it to your project.

这是由于缺少commons-logging.jar引起的。要修复它,请下载commons日志库并将其添加到项目中。