gpt4 book ai didi

java.lang.NoClassDefFoundError :-Could not initialize class org. apache.http.impl.conn.ManagedHttpClientConnectionFactory

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:44:36 32 4
gpt4 key购买 nike

我正在开发 Spring 网络服务 (SpringWSTemplate),我正在尝试覆盖 org.springframework.ws.transport.http.HttpComponentsMessageSender我有如下代码:

public class CustomHttpComponentsMessageSender extends
org.springframework.ws.transport.http.HttpComponentsMessageSender {
@Override
public WebServiceConnection createConnection(URI uri) throws IOException {

CookieStore cookieStore = new BasicCookieStore();
HttpComponentsConnection conn = (HttpComponentsConnection) super
.createConnection(uri);
HttpClientBuilder httpClientBuilder=HttpClientBuilder.create();
HttpClient httpclient = httpClientBuilder.setDefaultCookieStore(cookieStore).build();
HttpPost httpGet = new HttpPost(uri);
HttpResponse response = httpclient.execute(httpGet);
return conn;
}

}

当代码执行到行时:HttpClient httpclient = httpClientBuilder.setDefaultCookieStore(cookieStore).build();

我得到以下异常

INFO   | jvm 1    | main    | 2015/03/12 14:48:41.707 | Mar 12, 2015 2:48:41 PM org.apache.catalina.core.StandardWrapperValve invoke
INFO | jvm 1 | main | 2015/03/12 14:48:41.709 | SEVERE: Servlet.service() for servlet [DispatcherServlet] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.impl.conn.ManagedHttpClientConnectionFactory] with root cause
INFO | jvm 1 | main | 2015/03/12 14:48:41.709 | java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.impl.conn.ManagedHttpClientConnectionFactory
INFO | jvm 1 | main | 2015/03/12 14:48:41.710 | at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.<init>(PoolingHttpClientConnectionManager.java:487)
INFO | jvm 1 | main | 2015/03/12 14:48:41.710 | at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:147)
INFO | jvm 1 | main | 2015/03/12 14:48:41.710 | at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:136)
INFO | jvm 1 | main | 2015/03/12 14:48:41.710 | at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:112)
INFO | jvm 1 | main | 2015/03/12 14:48:41.710 | at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:726)
INFO | jvm 1 | main | 2015/03/12 14:48:41.710 | at com.utas.integrations.documentum.webservices.impl.CustomHttpComponentsMessageSender.createConnection(CustomHttpComponentsMessageSender.java:30)
INFO | jvm 1 | main | 2015/03/12 14:48:41.710 | at org.springframework.ws.client.support.WebServiceAccessor.createConnection(WebServiceAccessor.java:107)
INFO | jvm 1 | main | 2015/03/12 14:48:41.710 | at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:535)
INFO | jvm 1 | main | 2015/03/12 14:48:41.710 | at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:386)
INFO | jvm 1 | main | 2015/03/12 14:48:41.710 | at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:380)
INFO | jvm 1 | main | 2015/03/12 14:48:41.710 | at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:372)
INFO | jvm 1 | main | 2015/03/12 14:48:41.710 | at

我在我的构建路径中使用 jars,并且我的类路径中有 jars 条目。

<classpathentry kind="lib" path="lib/httpclient-4.3.3.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.3.jar"/>
<classpathentry kind="lib" path="/sapadtreco/lib/httpmime-4.3.1.jar"/>
<classpathentry kind="lib" path="lib/spring-ws-core-2.1.4.RELEASE.jar"/>
<classpathentry kind="lib" path="lib/fluent-hc-4.3.jar"/>

非常感谢快速帮助。

最佳答案

这可能是由于类路径中的 httpclient-4.3.3.jar 文件无效/损坏/缺失所致。尝试分解此文件并检查其是否有效并在其中包含 ManagedHttpClientConnectionFactory 类。

关于java.lang.NoClassDefFoundError :-Could not initialize class org. apache.http.impl.conn.ManagedHttpClientConnectionFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29006744/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com