I use the maven-assembly-plugin to create a jar-with-dependencies. When I execute the .jar file it throws
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at com.dg.fs.test.integration.main.FSIntegrationTestMain.<clinit>(FSIntegrationTestMain.java:26)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
This is a submodule, but I don't know why that would matter.
I've built lots of jar-with-dependencies with this plugin in the past. Now it is missing the transitive dependencies. What's the problem?
Thanks.
Here's the pom.xml.
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>fs-integration-test</artifactId>
<parent>
<groupId>com.dg</groupId>
<artifactId>fs-parent</artifactId>
<version>4.42-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>com.dg</groupId>
<artifactId>fs-jaxb-client</artifactId>
<version>4.55.0.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>com.arcitecta.mf</groupId>
<artifactId>mfclient</artifactId>
<scope>compile</scope>
<!-- <version>4.0.065</version> -->
</dependency>
<dependency>
<groupId>com.digital.globe.dmp</groupId>
<artifactId>mediaflux-utils</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.dg.fs.test.integration.main.FSIntegrationTestMain</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
You nailed it, SiKing. In the parent pom.xml it was <scope>provided</scope>
. I changed it to <scope>compile</scope>
in the project pom.xml and it is working correctly.