Invalid signature file digest for Manifest main attributes exception while trying to run jar file

Fay007

I am trying to run the jar file of my project. I am working on intelliJ and have use artifacts to generate the jar file. But everytime i am trying to run my jar file its giving me exception.

java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
    at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:284)
    at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:238)
    at java.util.jar.JarVerifier.processEntry(JarVerifier.java:316)
    at java.util.jar.JarVerifier.update(JarVerifier.java:228)
    at java.util.jar.JarFile.initializeVerifier(JarFile.java:383)
    at java.util.jar.JarFile.getInputStream(JarFile.java:450)
    at sun.misc.JarIndex.getJarIndex(JarIndex.java:137)
    at sun.misc.URLClassPath$JarLoader$1.run(URLClassPath.java:839)
    at sun.misc.URLClassPath$JarLoader$1.run(URLClassPath.java:831)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.misc.URLClassPath$JarLoader.ensureOpen(URLClassPath.java:830)
    at sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:803)
    at sun.misc.URLClassPath$3.run(URLClassPath.java:530)
    at sun.misc.URLClassPath$3.run(URLClassPath.java:520)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.misc.URLClassPath.getLoader(URLClassPath.java:519)
    at sun.misc.URLClassPath.getLoader(URLClassPath.java:492)
    at sun.misc.URLClassPath.getNextLoader(URLClassPath.java:457)
    at sun.misc.URLClassPath.getResource(URLClassPath.java:211)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:365)
    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:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" 

And this is my manifest file:

Manifest-Version: 1.0
Main-Class: Main

Then the external libraries added to my project

enter image description here

What am i doing wrong??

update

enter image description here

hagrawal

Some of your dependency JARs is a signed JAR, so when you combine then all in one JAR and run that JAR then signature of the signed JAR doesn't match up and hence you get the security exception about signature mis-match.

To fix this you need to first identify which all dependency JARs are signed JARs and then exclude them. Depending upon whether you are using MAVEN or ANT, you have to take appropriate solution. Below are but you can read more here, here and here.

Maven:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.6</version>
    <executions>
        <execution>
            <id>unpack-dependencies</id>
            <phase>package</phase>
            <goals>
                <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
                <excludeScope>system</excludeScope>
                <excludes>META-INF/*.SF</excludes>
                <excludes>META-INF/*.DSA</excludes>
                <excludes>META-INF/*.RSA</excludes>
                <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
                <outputDirectory>${project.build.directory}/classes</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

ANT:

<jar destfile="app.jar" basedir="${classes.dir}">
    <zipfileset excludes="META-INF/**/*" src="${lib.dir}/bcprov-jdk16-145.jar"></zipfileset>
    <manifest>
        <attribute name="Main-Class" value="app.Main"/>
    </manifest>
</jar>

Update based on OP's comment:

"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.

If these signature files are not excluded then security exception will occur because of signature mismatch.

How to know if a JAR is signed or not?: If a JAR contains files like files like .SF, .RSA or .DES or other algorithms files, then it is a signed JAR. Or run jarsigner -verify jarname.jar and see if it outputs "verified"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

LeanFT TestExportTool - Invalid signature file digest for Manifest main attributes

From Dev

Invalid signature file digest for Manifest main attributes w/ Jetty and Maven Shade Plugin

From Dev

Invalid signature file digest for Manifest main attributes w/ Jetty and Maven Shade Plugin

From Dev

Spark & Maven: SecurityException: Invalid Signature file digest for Manifest

From Java

"Invalid signature file" when attempting to run a .jar

From Java

"ClassNotFoundException" while trying to run .jar file

From Dev

Failing to run jar file from command line: “no main manifest attribute”

From Dev

no main manifest attribute (But I have the manifest file in the jar)

From Dev

Trying to run a jar file with bat

From Dev

Exception when trying to access Resources in jar file

From Dev

Exception when trying to access Resources in jar file

From Dev

IOException: 'Invalid header field; when creating .jar file with manifest

From Dev

Java can't execute jar file no main manifest attribute

From Dev

"no main manifest attribute" after downloading a .jar file in Java

From Dev

Open Source Jar file and Failed to load Main-Class manifest

From Dev

Error while trying to extract jar file

From Dev

Updating jar manifest file - java.io.IOException: invalid manifest format

From Dev

Updating jar manifest file - java.io.IOException: invalid manifest format

From Dev

Xcode File not found while trying to run app

From Dev

Run java jar - no main manifest attribute error

From Dev

Confusion on Uses of Jar Manifest File

From Dev

Installation of the application failed. XAP package signature is not valid or the WP manifest file is invalid.

From Dev

Invalid URL or resource not found when trying to execute JAR file

From Dev

Java Security Exception Invalid SHA1 Jar file

From Dev

Exception in main thread when executing java jar file

From Java

Fat JAR not working. "No Main Manifest Attribute". Tried POM file, still failing

From Dev

SecurityException during executing jnlp file (Missing required Permissions manifest attribute in main jar)

From Dev

How to produce a jar file for existing maven project without (no main manifest attribute)?

From Dev

a java exception has occured while opening .jar file

Related Related

  1. 1

    LeanFT TestExportTool - Invalid signature file digest for Manifest main attributes

  2. 2

    Invalid signature file digest for Manifest main attributes w/ Jetty and Maven Shade Plugin

  3. 3

    Invalid signature file digest for Manifest main attributes w/ Jetty and Maven Shade Plugin

  4. 4

    Spark & Maven: SecurityException: Invalid Signature file digest for Manifest

  5. 5

    "Invalid signature file" when attempting to run a .jar

  6. 6

    "ClassNotFoundException" while trying to run .jar file

  7. 7

    Failing to run jar file from command line: “no main manifest attribute”

  8. 8

    no main manifest attribute (But I have the manifest file in the jar)

  9. 9

    Trying to run a jar file with bat

  10. 10

    Exception when trying to access Resources in jar file

  11. 11

    Exception when trying to access Resources in jar file

  12. 12

    IOException: 'Invalid header field; when creating .jar file with manifest

  13. 13

    Java can't execute jar file no main manifest attribute

  14. 14

    "no main manifest attribute" after downloading a .jar file in Java

  15. 15

    Open Source Jar file and Failed to load Main-Class manifest

  16. 16

    Error while trying to extract jar file

  17. 17

    Updating jar manifest file - java.io.IOException: invalid manifest format

  18. 18

    Updating jar manifest file - java.io.IOException: invalid manifest format

  19. 19

    Xcode File not found while trying to run app

  20. 20

    Run java jar - no main manifest attribute error

  21. 21

    Confusion on Uses of Jar Manifest File

  22. 22

    Installation of the application failed. XAP package signature is not valid or the WP manifest file is invalid.

  23. 23

    Invalid URL or resource not found when trying to execute JAR file

  24. 24

    Java Security Exception Invalid SHA1 Jar file

  25. 25

    Exception in main thread when executing java jar file

  26. 26

    Fat JAR not working. "No Main Manifest Attribute". Tried POM file, still failing

  27. 27

    SecurityException during executing jnlp file (Missing required Permissions manifest attribute in main jar)

  28. 28

    How to produce a jar file for existing maven project without (no main manifest attribute)?

  29. 29

    a java exception has occured while opening .jar file

HotTag

Archive