Intellij Fat One Jar Artifact Does Not Generate a Working Output

Intellij fat one jar artifact does not generate a working output

mssql-jdbc-6.2.0.jre8.jar has the digital signature (MSFTSIG.RSA and MSFTSIG.SF files). When the jar is repackaged, the signature becomes broken. If you remove these files from the jar (either original one or the artifact), it should start fine.

Vote for this issue to get it addressed in the future updates.

Jar Built by IntelliJ not recognizing libraries inside jar

            <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>sample.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<archive>
<manifest>
<mainClass>sample.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

The previous maven set up solved this issue for me. Then I ran mvn clean package and it is working.

IntelliJ artifact JAR file: Could not find or load main class

apache-commons.jar is digitally signed (you can tell it by the FILETEST.DSA and FILETEST.SF in the META-INF directory).

When the artifact jar is packaged, these files are copied into the new jar, but they do not contain the signatures for other classes in your new jar.

This breaks the jar signature and JVM doesn't allow the execution of the jar for the security reasons.

See my another answer for the workaround (just delete *.SF and *.DSA files from apache-commons.jar and rebuild the artifact).

IntelliJ doesn't create jar properly

IntelliJ didn't automatically build the artifact.

So I had to build it manually: (Build > Build Artifacts...)

IntelliJ Build Artifact causes executable .jar to ignore Class-Path setting

Try, when creating an artifact in IntelliJ,project structure -> Artifacts -> new from maven with dependencies, in the path for Directory for the META-INF/MANIFEST.MF, always change the path to the sibling resources directory, it should not be set tojava` directory.



Related Topics



Leave a reply



Submit