GitLab CI always fail running pure Java with external dependencies

Hi Everyone!

I need to run a Java app with CI, but I can’t get it to work. It builds an artifact before (which if I download works normally on any platform - Windows, Linux), but it can’t run in the next stage…It says:

Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/commons/io/FilenameUtils

The apache commons io is included inside the jar as a jar. Its not the best solution, but this project doesn’t allow us to use anything, but pure Java.

Why this doesn’t work on GitLab CI?

Thanks.

Hello! I hope the following info may help you investigate your issue deeper.

While it’s possible that this is due to a classpath mismatch between compile-time and run-time, it’s not necessarily true.

  1. java.lang.ClassNotFoundException This exception indicates that the class was not found on the classpath. This indicates that we were trying to load the class definition, and the class did not exist on the classpath.
  2. java.lang.NoClassDefFoundError This exception indicates that the JVM looked in its internal class definition data structure for the definition of a class and did not find it. This is different than saying that it could not be loaded from the classpath. Usually this indicates that we previously attempted to load a class from the classpath, but it failed for some reason - now we’re trying to use the class again (and thus need to load it, since it failed last time), but we’re not even going to try to load it, because we failed loading it earlier (and reasonably suspect that we would fail again). The earlier failure could be a ClassNotFoundException or an ExceptionInInitializerError (indicating a failure in the static initialization block) or any number of other problems. The point is, a NoClassDefFoundError is not necessarily a classpath problem.

explicitly telling java -Djava.ext.dirs= also not solving the issue , appriciate if someone helps