0

I have a problem with a maven dependency on a J2ee project (EAR + WAR). More in detail:

In the WAR project pom I have a JAR application dependency:

<dependency>
    <groupId>JAR_APP_groupid</groupId>
    <artifactId>JAR_APP_artifactid</artifactId>
    <version>JAR_APP_version</version>
</dependency>

the above JAR (JAR_APP) is made by another Maven project which contains the follow dependency:

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

The problem is that when I build the WAR I see the JAR_APP dependency and the httpclient (sub)dependency in the lib folder, but when I run the application on the application server (websphere 9.0) I get the following error:

Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpUriRequest

I don't know why. Can you help me ?

Thank you a lot.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
antopas
  • 23
  • 5

1 Answers1

0

WebSphere already uses Apache Http Components and the classloader picks the one from the system. I think it is possible to change the order the AS loads the dependencies (Parent last).

halfer
  • 19,824
  • 17
  • 99
  • 186
Beppe C
  • 11,256
  • 2
  • 19
  • 41
  • I tried to define the org.apache.httpcomponents as provided scope. I also tried to exclude the dependency on the WAR pom... but the problem is still there – antopas Jan 05 '20 at 17:04
  • The version is WebSphere might not have the method invoked by JAR_APP_artifactid. Changing the scope you still do not change which version runs on WebSphere. – Beppe C Jan 05 '20 at 17:10