I was working on a project and we needed an executable jar will the dependencies in. So I googled and found maven-assembly-plugin. So I took the plugin and used it build my executable jar. After running the executable the log4j2 stopped to work. I tried to build the executable with log4j2.xml in src/main/resources but the log4j2 still complained about the config file not found and I once again passesd the log4j2.xml in the param -Dlog4j.configurationFile and it still didnot work. So after wasting half a day I started googling and found maven-shade-plugin. Once I used the maven-shade-plugin log4j2 started to work again without anything else to be done.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.4.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <manifestEntries> <Main-Class>MainClass</Main-Class> </manifestEntries> </transformer> </transformers> </configuration> </execution> </executions> </plugin>