Log4j2 configuration not found when running standalone application built by shade plugin

ok I found this issue about this problem. In short, the problem arises when application classes are packaged in uber jar using maven shade plugin. While for log4j2 version 2.8.1 the fix is still pending, the suggested workaround is to update maven pom.xml with extra configuration settings for shade plugin as follow: <project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” … Read more

How to create spring-based executable jar with maven?

You can add the following configuration so that the contents of the .schema files from all the jars get appended together. <configuration> <transformers> <transformer implementation=”org.apache.maven.plugins.shade.resource.AppendingTransformer”> <resource>META-INF/spring.handlers</resource> </transformer> <transformer implementation=”org.apache.maven.plugins.shade.resource.AppendingTransformer”> <resource>META-INF/spring.schemas</resource> </transformer> </transformers> </configuration>

Maven build [WARNING] we have a duplicate class

Take a look at the “Dependency Exclusions” section in the Maven doc. In your provided example, I’ll exclude the commons-logging:commons-logging-api:jar:1.0.4:compile dependency from org.apache.hadoop.hive:hive-common:jar:0.7.1-cdh3u3:compile. In your pom.xml : <dependency> <groupId>org.apache.hadoop.hive</groupId> <artifactId>hive-common:jar</artifactId> <version>0.7.1-cdh3u3</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId> </exclusion> </exclusions> </dependency>

How to include test classes in Jar created by maven-shade-plugin?

Answering late, but got a working solution which may help future visitors of this question. I succeed on having a fat jar using only one Maven plugin and including: The test classes The application code classes External dependencies required by application code (in compile scope) External dependencies required by the test code (in test scope) … Read more

Invalid or corrupt JAR File built by Maven shade plugin

On my end if I build your project using the pom.xml you’ve showed us, with apache-poi declared after jfreechart, then as you’ve mentioned I get a corrupt JAR. Swapping the order of these two dependencies indeed gives me a correct JAR. I’ve some previous experience with the maven-shade-plugin and when I used it I had … Read more

Is dependency-reduced-pom.xml automatically used instead of pom.xml?

The dependency-reduced-pom.xml is generated at build time into ${basedir} of the project. This file is a temporary file that is only used for packaging into the shaded jar. Quoting the documentation of the createDependencyReducedPom attribute: Flag whether to generate a simplified POM for the shaded artifact. If set to true, dependencies that have been included … Read more

How can I remove module-info.class warning for a shaded .jar?

Filtering out the file in the shade plugin seems to work fine for me. Here’s what my maven-shade-plugin config looks like: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.1</version> <configuration> <filters> <filter> <artifact>*:*</artifact> <excludes> <exclude>module-info.class</exclude> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> The key line is the <exclude>module-info.class</exclude>. The filter … Read more

What is a shaded JAR file? And what is the difference/similarities between an uber JAR and shaded JAR? [duplicate]

I’ll explain what an uber JAR is first because this underpins the shading explanation. Uber JAR An uber JAR is a JAR which contains the contents of multiple JARs (or, less commonly, multiple other JARs themselves) Your application will almost certainly use other packages and these packages might be provided as JARs. When using Maven … Read more

log4j2 ERROR StatusLogger Unrecognized conversion specifier

If a dependency contains log4j2 plugin, a Log4j2Plugins.dat cache file is included in the jar. When the Maven shade plugin is used to merge multiple jars with a Log4j2Plugins.dat file, only one will survive. Without the plugin definitions, errors are shown on startup. Log4j2 issue One solution for this is excluding Log4j2Plugins.dat cache file from … Read more

Maven shade plugin adding dependency-reduced-pom.xml to base directory

You can avoid having it created by setting createDependencyReducedPom to false. e.g. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>${maven-shade-plugin.version}</version> <configuration> <createDependencyReducedPom>false</createDependencyReducedPom> </configuration> …. …. </plugin> See http://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html#createDependencyReducedPom <createDependencyReducedPom> Flag whether to generate a simplified POM for the shaded artifact. If set to true, dependencies that have been included into the uber JAR will be removed from the section … Read more

tech