I am trying to build with maven and run a jar that imports the apache commons fileupload library.
I have included in my pom.xml the below dependencies
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
Running mvn clean package
works with no errors.
But running the jar file with
java -cp .\target\XXX-server-1.0-SNAPSHOT.jar XXX.MainClass
produces the error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
I searched for a solution to this problem and the closest I found was java.lang.NoClassDefFoundError:org/apache/commons/fileupload/FileItemFactoryin Spring MVC, but am not sure where to find the "deployment" folder or if that is applicable to me as I am trying to run the jar in the target
directory.
Do I need to move the actual fileupload library jar or some other file to get this to work? Thanks.