oxicod
oxicod

Reputation: 33

ClassNotFoundException on Maven Dependency Class org.apache.http.client

I'm trying to build a simple API client, which uses org.apache.httpfor connecting to the API server. Locally everything works fine. I'm successfully connecting to the server and receive the data I want.

But, when I deploy my application to the server. I'm getting following exception: Caused by: java.lang.ClassNotFoundException: org.apache.http.client.ClientProtocolException from [Module "deployment.adobe-livecycle-jboss.ear:main" from Service Module Loader]

I tried multiple different variants of versions of my depencies. Right now im using the following:

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpcore</artifactId>
    <version>4.4.3</version>
    <scope>compile</scope>
</dependency>
        
<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.1</version>
    <scope>compile</scope>
</dependency>

Both of the JARs appear in my Java Build Path, also the class which is "missing" is found in there. Even when I build the project and search the JAR files libs folder, I can find the class...

I know there are some solutions to find online but none of them helped me.

Upvotes: 0

Views: 1510

Answers (1)

Yassir Khaldi
Yassir Khaldi

Reputation: 1762

This is probably caused by a faulty maven local repository. Try looking for your maven local repository (It's generally a hidden folder like named.m2\repository), delete the folder org\apache\httpcomponents then clean compile your project.


Edit: After further explanation of the problem, it seems that this is a deployment issue not a build one.

If it's the first time that you use this package in your build, then this package's jar must be defined somewhere in the deployment server, it seems that you are deploying in an Adobe environment which seems to be based on JBoss because of that line of log that you provided

[Module "deployment.adobe-livecycle-jboss.ear:main" from Service Module Loader]

Make sure to read the documentation of that environment on how to configure and define external modules.

Upvotes: 1

Related Questions