简体   繁体   中英

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

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.

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.

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

这是由于缺少commons-logging.jar造成的。要解决此问题,请下载commons日志库并将其添加到您的项目中。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM