NoClassDefFoundError in Spring Boot: Issues with Local JAR Dependencies

45 views Asked by At

My Spring Boot application has a dependency on a local JAR. I can run it on my machine, but when I generate the Docker image, I encounter the NoClassDefFoundError.

My pom:

Attemp 1:

<dependency>
    <groupId>com.amdocs.adh.impl</groupId>
    <artifactId>target-aldmpaymentarrangementfastdata</artifactId>
    <version>20.06.02-SNAPSHOT</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/lib/target-paymentfastdata-20.06.02-SNAPSHOT.jar</systemPath>
</dependency>

Attemp 2:

I tried to set it to an absolute system path.

<systemPath>/lib/target-paymentfastdata-20.06.02-SNAPSHOT.jar</systemPath>

In the Docker, I copied the JAR. In the generated image, it exists in two locations:

/lib/target-paymentfastdata-20.06.02-SNAPSHOT.jar

/workspace/app/BOOT-INF/classes/lib/target-paymentfastdata-20.06.02-SNAPSHOT.jar

The error occurs only at runtime, at the moment when the class is about to be used, when I run the Docker container.

Running the code directly through the IDE or command line works fine.

0

There are 0 answers