java.lang.NoClassDefFoundError: org/apache/http/impl/conn/PoolingClientConnectionManager

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25273268/
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-11-02 07:45:24  来源:igfitidea点击:

java.lang.NoClassDefFoundError: org/apache/http/impl/conn/PoolingClientConnectionManager

javaspringmaven-2maven-plugin

提问by Dean

Getting an issue with this dependency although it isn't being referenced as a dependency explicitly in my pom.xml. The actual maven dependency is:

尽管在我的 pom.xml 中没有明确地将其作为依赖项引用,但此依赖项出现问题。实际的 maven 依赖是:

  <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.2.5</version>
    </dependency>

The stacktrace from my console is:

我的控制台的堆栈跟踪是:

 java.lang.NoClassDefFoundError: org/apache/http/impl/conn/PoolingClientConnectionManager
at com.gbi.gsa.Bridge.createClient(Bridge.java:50)
at com.gbi.gsa.Bridge.<init>(Bridge.java:46)
at com.gbi.gsa.SimpleBridge.<init>(SimpleBridge.java:34)
at   com.gbi.quickstart.controller.NavigationController.handleRequestInternal(NavigationController.java:114)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1336)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException:   org.apache.http.impl.conn.PoolingClientConnectionManager
at   org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:430)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:383)
... 41 more

I have tried deleting my .m2/repositories directory and downloading my dependencies (through maven) and it still doesn't work.

我尝试删除我的 .m2/repositories 目录并下载我的依赖项(通过 maven),但它仍然不起作用。

回答by kiwiron

Your problem is probably nothing to do with dependencies. NoClassDefFoundError is different to ClassNotFoundException. It means that the class was available while compiling, but failed to initialise, usually due to an exception in a static block. This answer has the good oil. What causes and what are the differences between NoClassDefFoundError and ClassNotFoundException?

您的问题可能与依赖项无关。NoClassDefFoundError 与 ClassNotFoundException 不同。这意味着该类在编译时可用,但未能初始化,通常是由于静态块中的异常。这个答案有很好的油。NoClassDefFoundError 和 ClassNotFoundException 的原因和区别是什么?

回答by wolktm

Try upgrading to 4.3

尝试升级到 4.3

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.3.3</version>
</dependency>

I think the class was not present until 4.3

我认为这门课直到 4.3 才出现

回答by Shweta M

Try by changing the httpClient version from 4.2.5 to 4.3.4... It worked for me...

尝试将 httpClient 版本从 4.2.5 更改为 4.3.4 ......它对我有用......

回答by Ben

As it works for me, please post your original pom. Also check if you are behind a proxy and your .m2/settings is valid.

因为它对我有用,请发布您的原始 pom。还要检查您是否在代理后面并且您的 .m2/settings 是否有效。

回答by Hrushi

Please check the version of the servlet-api that you are using in your project and also in the poms of the third party jars like Spring-web, httclient etc. If spring jar is compiled with servlet version 3.0.1 and httpclient or its dependencies are compiled with servlet 2.5.6 then this problem might occur.

请检查您在项目中使用的 servlet-api 的版本以及在第三方 jars 的 poms 中(如 Spring-web、httclient 等)。如果 spring jar 是使用 servlet 版本 3.0.1 和 httpclient 或其依赖项编译的是用servlet 2.5.6 编译的,那么可能会出现这个问题。

I have faced similar issue while upgrading some of the third party dependencies for my project.

在为我的项目升级某些第三方依赖项时,我遇到了类似的问题。