Invalid signature file digest error
What's inside this article
⌄
- Invalid signature file digest error
- JAR signature digest error fix
- Invalid signature manifest error
- Fix signature verification error
Full error text:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
This error can be encountered if there are signed libraries among the dependencies of your project. To solve the problem, you need to exclude files with the extensions .SF, .DSA, .RSA from the build.
Of course, we will assume that you are building uber jar (fat jar).
For Maven:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<executions>
<execution>
...
<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>
</execution>
</executions>
</plugin>
For Gradle (Kotlin DSL):
exclude("META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA")
Complete code of the build task:
tasks.register<Jar>("uberJar") {
archiveClassifier.set("uber")
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from({
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
})
exclude("META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA")
}