peter bence
peter bence

Reputation: 822

IntelliJ Jar Error : Invalid signature file digest for Manifest main attributes

I'm using IntelliJ IDE on an armx64 linux-based system, where i'm working on a non-maven java project that have a lot of modules (dependencies) linked to it. When running my project from the IDE everything works fine, however when building it into a runnable jar file and trying to run the jar from the terminal, using java -jar myjar.jar, i got the following error:

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
    at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:330)
    at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:263)
    at java.util.jar.JarVerifier.processEntry(JarVerifier.java:318)
    at java.util.jar.JarVerifier.update(JarVerifier.java:230)
    at java.util.jar.JarFile.initializeVerifier(JarFile.java:383)
    at java.util.jar.JarFile.getInputStream(JarFile.java:450)
    at sun.misc.URLClassPath$JarLoader$2.getInputStream(URLClassPath.java:977)
    at sun.misc.Resource.cachedInputStream(Resource.java:77)
    at sun.misc.Resource.getByteBuffer(Resource.java:160)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:454)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)

I'm currently using OpenJdk-1.8, i tried to use Oracle JDK v1.8 instead to build and then rerun the jar file, but still facing the same error. I'd also tried to create a new simple "Hello world" application and export a corresponding jar for it where it runs successfully without errors.

Here is my jar internal structure and the corresponding manifist file: jar structure screenshot

Upvotes: 3

Views: 13391

Answers (1)

peter bence
peter bence

Reputation: 822

Thanks for @y.bedrov who linked to this issue that helped my solving the error, where it includes the following:

"sqljdbc4.jar" was the signed JAR in OP's external libraries. So, following above approach to systematically exclude the signature related files like .SF, .RSA or .DES or other algorithms files is the right way to move forward.

And yes I'm also using "sqljdbc4.jar", so after reading the answer i decided to solve the problem by deleting the signature files from my Meta-inf folder inside my jar file.

Upvotes: 6

Related Questions