skip to Main Content

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 –
enter image description here

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


  1. 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.

    mvn install:install-file -Dfile=${pom.basedir}/libs/suitetalk-axis-proxy-v2022_1-1.0.0.jar -DgroupId=org.suitetalk -DartifactId=suitetalk-axis-proxy-v2022_1 -Dversion=1.0.0 -Dpackaging=jar
    
    Login or Signup to reply.
  2. You are missing the instruction for the spring-boot-maven-plugin to copy the system scope into the spring-boot jar.

    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <includeSystemScope>true</includeSystemScope>
        </configuration>
    </plugin>
    

    Also pom. in ${pom.basedir} is redundant:

    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc</artifactId>
        <version>11.2.0.3</version>
        <scope>system</scope>
        <systemPath>${basedir}/libs/suitetalk-axis-proxy-v2022_1-1.0.0.jar</systemPath>
    </dependency>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search