I have added 3 external jars which is not present on the maven repository. I mentioned external jars as a system scope in pom.xml file –
<dependency>
<groupId>org.suitetalk</groupId>
<artifactId>suitetalk-axis-proxy-v2022_1</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<type>jar</type>
<systemPath>${pom.basedir}/libs/suitetalk-axis-proxy-v2022_1-1.0.0.jar</systemPath>
</dependency>
In STS/Eclipse, the project is not giving errors and all functionality is working well as expected. But if we build project by – mvn clean package
then also it is not throwing any error. When I run docker image by docker run command then getting error as –
Summary – External Jar’s classes are not found while running the docker image. getting error as NoClassDefFOund error.
Can someone please help me to solve this issue ?
Thanks in advance for your efforts!
Regards,
Prashant VIDHATE
2
Answers
That is because java runtime is looking for them inside the docker container. To make it work, you need to add the libraries to docker image (
ADD
command in Dockerfile) or add the volume to map your local filesystem folder into the container filesystem folder.You can also install the dependencies into your local maven repository, and then they will be included in the "fat jar" after build.
You are missing the instruction for the spring-boot-maven-plugin to copy the system scope into the spring-boot jar.
Also
pom.
in${pom.basedir}
is redundant: