简体   繁体   English

如何在带有EAR项目的wildfly 10中使用httpcomponents?

[英]How to use httpcomponents in wildfly 10 with EAR project?

I can't get org.apache.httpcomponents to work in Wildfly 10. I didn't try 9. The error I get is, basically. 我无法使org.apache.httpcomponents在Wildfly 10中工作。我没有尝试过9。我得到的错误基本上是。

Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpUriRequest from [Module "deployment.opca-ear.ear.opca-ejb.jar:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
    ... 185 more

I looked at Wildfly 8.1 ClassNotFound org.apache.http.conn.ClientConnectionManager , but jboss-deployment-structure.xml described there is not working here. 我查看了Wildfly 8.1 ClassNotFound org.apache.http.conn.ClientConnectionManager ,但是描述的jboss-deployment-structure.xml在这里不起作用。

I tried various combinations of things in the POM file, but I'm not getting anywhere with that. 我尝试了POM文件中的各种组合,但是我对此一无所知。

The class fails when being constructed, so the import statements are causing problems. 该类在构造时会失败,因此import语句会引起问题。

I haven't been able to get access to the module or get the needed jar files to be deployed into the ear lib directory. 我无法访问该模块或无法将所需的jar文件部署到ear lib目录中。

EDIT: I'm using JBoss Developer Studio. 编辑:我正在使用JBoss Developer Studio。 I seem to be making some progress in that if I copy my opca-ear.ear file to the deployment directory manually then the httpclient and httpcore jars get deployed, but they don't if I deploy from jbstudio, so I guess it's an issue with jboss-modules.jar deployments. 我似乎正在取得一些进展,如果我将我的opca-ear.ear文件手动复制到部署目录中,则将部署httpclient和httpcore jar,但是如果我从jbstudio进行部署,它们将不会部署,所以我想这是一个问题使用jboss-modules.jar部署。 Not being able to debug/deploy from jbstudio is going to be a pain. 无法从jbstudio进行调试/部署会很痛苦。 Httpclient and httpcore are in my opca-ear.ear file in the lib directory, as well as the ejb/target/opca-ear/lib directory. Httpclient和httpcore在我的lib目录的opca-ear.ear文件以及ejb / target / opca-ear / lib目录中。

If I could get something like jboss-deployment-structure.xml or perhaps an entry in the a manifest file working so that wildfly provides the client access to the org.apache.httpcomponents resources then I wouldn't have to worry about jboss-modules.jar . 如果我能得到类似jboss-deployment-structure.xml或清单文件中的条目的信息,以便wildfly为客户端提供对org.apache.httpcomponents资源的访问,那么我就不必担心jboss-modules.jar

SOLUTION: As noted in the accepted answer, jboss-deployment-structure.xml only works on "full" deployments, so I used a manifest.mf entry 解决方案:如已接受的答案所述, jboss-deployment-structure.xml仅适用于“完整”部署,因此我使用了manifest.mf条目。

Dependencies: org.apache.httpcomponents

and updated the maven-ejb-plugin to use it: 并更新了maven-ejb-plugin以使用它:

<artifactId>maven-ejb-plugin</artifactId>
<version>2.5.1</version>
<configuration>
  <!-- Tell Maven we are using EJB 3.1 -->
  <ejbVersion>3.1</ejbVersion>
  <archive>
    <manifestFile>${basedir}/src/main/resources/META-INF/manifest.mf</manifestFile>
  </archive>
</configuration>

It all depends on which code needs it. 这完全取决于哪个代码需要它。 The jboss-deployment-structure.xml you are mentionning isn't going to work if you don't declare your 'full' application. 如果您未声明“完整”应用程序,那么您提到的jboss-deployment-structure.xml将无法正常工作。
Maybe you should just add a Manifest with the entry Dependencies: org.apache.httpcomponents in the jar/war that needs it. 也许您只需在需要它的jar / war中添加带有Dependencies:org.apache.httpcomponents条目的清单。
Tkae a look at https://docs.jboss.org/author/display/WFLY10/Class+Loading+in+WildFly 看看https://docs.jboss.org/author/display/WFLY10/Class+Loading+in+WildFly

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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