0
votes

I am using external jars added through scope = system with ${basedir}/src/main/java/... added as a systempath under the dependency sub group in pom.xml. Whenever I use the project locally from IntelliJ, there are no warnings or error. However when i try to start the .jar file from a docker container i get exceptions about the dependency.

I have tried adding the jars though Libraries under project structure in IntelliJ and just adding the jars in libs folder under the root. First i was providing the absolute path but then i changed it to ${basedir} because the absolute path wasn't mapped as a volume on the docker container. Is there any way i can pack the external jars with the project jar so i could use it in a docker container?

1
Provide the exception details. - Sambit
In the main project i call a constuctor for a class from the external jar and i cannot resolve the import. - LexByte
You need to show us how you create your docker image about that part. - davidxxx
its simple image using official flink docker image and i just copy the jars into it as so.. FROM flink:1.9 COPY ./jars ./jars - LexByte

1 Answers

0
votes

IIUC you have at least two options:

1. Add the JARs to a new image (per @LexByte suggestion above).

Assuming the JARs are in ${PWD}/jars on your host machine and you wish them in ${WORKDIR}/jars in the container:

FROM [[original-image]]
WORKDIR ...
COPY ./jars ./jars

Then, ensure your code references the JARs via the [[WORKDIR]]/jars/[[some-jar]]

NB [[WORKDIR]] is whatever you set as the container's working directory.

2. Mount the JARs into the container using the existing image:

docker run ... --volume=${PWD}/jars:[[WORKDIR]]/jars ...

NB [[WORKDIR]] is whatever you will use as the container's working directory. This is the location where the JARs will be mounted in the container.