有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java IntelliJ Jar错误:清单主属性的签名文件摘要无效

我在一个armx64 linux-based系统上使用IntelliJIDE,我在一个非mavenjava项目上工作,该项目有很多模块(依赖项)与之链接。当从IDE运行我的项目时,一切正常,但是当将其构建到可运行的jar文件中并尝试从终端使用java -jar myjar.jar运行jar时,我得到了以下错误:

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)

我目前正在使用OpenJdk-1.8,我尝试使用Oracle JDK v1。8来构建并重新运行jar文件,但仍然面临相同的错误。我还尝试创建一个新的简单的“Hello world”应用程序,并为它导出一个相应的jar,在那里它成功运行,没有错误

以下是我的jar内部结构和相应的manifist文件: jar structure screenshot


共 (1) 个答案

  1. # 1 楼答案

    感谢@y.bedrov链接到帮助我解决错误的issue,其中包括以下内容:

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

    是的,我也在使用“sqljdbc4.jar”,所以在阅读了答案后,我决定通过删除jar文件中Meta inf文件夹中的签名文件来解决这个问题