I am using two plugins to generate a runnable jar file with m2e plugin from eclipse. Here is the config:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<archive>
<manifest>
<mainClass>com.unlockservice.App</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
In additional to standard dependencies I have a couple of local ones wich are added in the following way:
<dependency>
<groupId>com.ejl</groupId>
<artifactId>CRMObjects</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/CRMObjects.jar</systemPath>
</dependency>
<dependency>
<groupId>com.ejl</groupId>
<artifactId>CRMPDFGenerators</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/CRMPDFGenerators.jar</systemPath>
</dependency>
After maven's build everything looks fine. All the libraries copied to lib folder. But when I copy both jar file and lib folder to the server and run the file with java -jar path-to-file.jar
it fails because can't find the classes from external libraries (CRMObjects.jar).
Any suggestions why it happens? Thank you in advance