Skip to content
Advertisement

getting a java.lang.ClassNotFoundException when starting a Docker container

I am having a problem starting a .jar file within a Docker Container. The error message I am getting is:

Exception in thread “main” java.lang.ClassNotFoundException: ccinfw.MainApplication

I have added information below. Why am I getting this error and how can I fix it?

TIA

Manifest File

JavaScript

ran jar -xvf BackEndRestFunctionality-0.0.1-SNAPSHOT.jar > expanded. Below is a portion of the output. MainApplication.class does exist in the jar file

JavaScript

I am using the following software

JavaScript

Maven Dependencies

enter image description here

I am getting the following error message when starting it:

JavaScript

the maven command executed within Jenkins

JavaScript

portion of pom.xml file responsible for building

JavaScript

the Dockerfile being accessed

JavaScript

Here is a part of the Jenkins log file where the Docker Image file is being built using the generated .jar file – again – the .jar file works fine when ran on its own

JavaScript

Docker Image Layers

JavaScript

Advertisement

Answer

I found out what the problem was – thank goodness for having a version in Gitlab to refer to (as well as a “previous” version on another machine)

Basically, I used Maven to put the project together. I executed the following command from Jenkins to build the .jar file

JavaScript

In the pom.xml file, I did not specify :

JavaScript

When I went ahead and set it

JavaScript

Docker started the jar file correctly and everything worked fine.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement