I have recently dockerized a maven / springboot project. It runs outside docker just fine, and it even starts in a docker container, but as soon as I try to interact with the application, I receive a java.lang.ClassNotFoundException
.
My understanding is that this has to do with the classpath, but why would the jar run locally and not in the docker container?
The class that is missing belongs to an external jar file that is in the project directory structure and listed in the pom.xml as a dependency:
<dependency>
<groupId>externalJar</groupId>
<artifactId>externalJar</artifactId>
<version>0.0.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/library/externalJar.jar</systemPath>
</dependency>
Here is my dockerfile:
FROM openjdk:8-alpine
RUN apk update && apk add bash
RUN mkdir -p /opt/app
ENV PROJECT_HOME /opt/app
COPY target/main.jar $PROJECT_HOME/main.jar
WORKDIR $PROJECT_HOME
EXPOSE 8282
CMD ["java", "-Djava.security.egd=file:/dev/./urandom","-jar","./main.jar"]
What am I missing?