I follow several entries here with solutions but still, I cannot make it work.
I have a Java application to be executed inside a Docker container, and that requires running with two JAR files in classpath
and I'm not able to make it with all these combinations in my Dockerfile
.
ENTRYPOINT [ "java", "-classpath", "app.jar;another.jar", "com.pol.Main" ]
CMD [ "java", "-classpath", "app.jar;another.jar", "com.pol.Main" ]
CMD [ "java", "-classpath", "app.jar:another.jar", "com.pol.Main" ]
CMD [ "java", "-classpath", "app.jar;/*", "com.pol.Main" ]
I know the app.jar
is there since if I add this one it's able to find the Main
class, but then it fails because it cannot find some Classes required from another.jar
With option 3
CMD [ "java", "-classpath", "app.jar:another.jar", "com.pol.Main" ]
I can find the main class of app.jar
but another.jar
is not loaded
java.util.NoSuchElementException: null
at java.util.ServiceLoader$2.next(ServiceLoader.java:1308) ~[?:?]
at java.util.ServiceLoader$2.next(ServiceLoader.java:1296) ~[?:?]
at java.util.ServiceLoader$3.next(ServiceLoader.java:1394) ~[?:?]
In local running with the command
java -cp "app.jar;./*" com.pol.Main
Works perfectly fine and Service provider load the instance fine.