0

I can't get org.apache.httpcomponents to work in Wildfly 10. I didn't try 9. The error I get is, basically.

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.

I tried various combinations of things in the POM file, but I'm not getting anywhere with that.

The class fails when being constructed, so the import statements are causing problems.

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.

EDIT: I'm using 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. Not being able to debug/deploy from jbstudio is going to be a pain. Httpclient and httpcore are in my opca-ear.ear file in the lib directory, as well as the ejb/target/opca-ear/lib directory.

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.

SOLUTION: As noted in the accepted answer, jboss-deployment-structure.xml only works on "full" deployments, so I used a manifest.mf entry

Dependencies: org.apache.httpcomponents

and updated the maven-ejb-plugin to use it:

<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>
Community
  • 1
  • 1
K.Nicholas
  • 10,956
  • 4
  • 46
  • 66
  • Where are the Http Components jars installed in your EAR file? In the EAR/lib directory? Do you have both httpclient and httpcore there? – Steve C Apr 28 '16 at 00:45
  • Hi @SteveC, see EDIT's. – K.Nicholas Apr 28 '16 at 03:57
  • Your deployment contains jboss-modules.jar? – Steve C Apr 28 '16 at 04:02
  • No. I think jbstudio/eclipse uses it do to its deployments. – K.Nicholas Apr 28 '16 at 04:30
  • Please show the pom.xml files that you are using. `jboss-deployment-structure.xml` is only useful if you want to use the Http Components that come with WildFly/JBossAS - something I don't recommend. The first step is to get a maven command line build of your application that creates correct artefacts. After that we can deal with the JBoss Developer Studio issues - if they still exist. – Steve C Apr 29 '16 at 00:13
  • @SteveC, my pom included org.apache.httpcomponents.httpclient which is what I wanted to use. Wildfly 10 is using version 4.5 of that, so having the container provide it is fine with me, and version 4.5 is good and recent, so I'm fine with that. Tx. – K.Nicholas Apr 29 '16 at 00:51

1 Answers1

2

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.
Maybe you should just add a Manifest with the entry Dependencies: org.apache.httpcomponents in the jar/war that needs it.
Tkae a look at https://docs.jboss.org/author/display/WFLY10/Class+Loading+in+WildFly

ehsavoie
  • 3,126
  • 1
  • 16
  • 14