gpt4 book ai didi

java - Wildfly 8.1 ClassNotFound org.apache.http.conn.ClientConnectionManager

转载 作者:行者123 更新时间:2023-11-29 05:13:16 25 4
gpt4 key购买 nike

我有一段时间让池连接管理器为 Resteasy 客户端工作。在 Wildfly 8.1 上部署。

import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine;
...

PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
cm.setMaxTotal(200);
cm.setDefaultMaxPerRoute(20);
HttpClient httpClient = new DefaultHttpClient(cm);
ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient);
ResteasyClient resteasyClient = new ResteasyClientBuilder().httpEngine(engine).build();

我收到错误:

19:04:59,355 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "ESM2.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"ESM2.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"ESM2.war\".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment \"ESM2.war\"
Caused by: java.lang.RuntimeException: JBAS018757: Error getting reflective information for class com.xxx.esm2.server.webservices.rest.arcgis.ClientBean with ClassLoader ModuleClassLoader for Module \"deployment.ESM2.war:main\" from Service Module Loader
Caused by: java.lang.NoClassDefFoundError: org/apache/http/conn/ClientConnectionManager
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.ClientConnectionManager from [Module \"deployment.ESM2.war:main\" from Service Module Loader]"}}

这是来自 POM 的条目:

    <dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.1</version>
<scope>provided</scope>
</dependency>

jar 已经在 Wildfly 模块目录中,因此是提供的范围。

如何为 Resteasy 客户端正确添加和配置池化连接管理器?

最佳答案

modules 目录中的 Jar 文件大部分是对你屏蔽的,供服务器实现使用。暴露 Java EE API 的异常(exception)情况。

最简单的解决方案是将这个 jar 包含在您的应用程序中。

或者,您可以编写一个 jboss-deployment-structure.xml 文件,如 Class Loading in WildFly 中所述。 .

例如:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<dependencies>
<module name="org.apache.httpcomponents"/>
</dependencies>
</deployment>
</jboss-deployment-structure>

关于java - Wildfly 8.1 ClassNotFound org.apache.http.conn.ClientConnectionManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27517758/

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