JavaFX 12 - 清单主要属性的无效签名文件摘要
JavaFX 12 - Invalid signature file digest for Manifest main attributes
我正在开发 JavaFX 12 示例,但是在生成要执行的 JAR 文件时出现此错误:
java -jar target/JRPrintPreview-1.0-SNAPSHOT.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 java.base/sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:336)
at java.base/sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:269)
at java.base/java.util.jar.JarVerifier.processEntry(JarVerifier.java:316)
at java.base/java.util.jar.JarVerifier.update(JarVerifier.java:230)
at java.base/java.util.jar.JarFile.initializeVerifier(JarFile.java:758)
at java.base/java.util.jar.JarFile.ensureInitialization(JarFile.java:1035)
at java.base/java.util.jar.JavaUtilJarAccessImpl.ensureInitialization(JavaUtilJarAccessImpl.java:69)
at java.base/jdk.internal.loader.URLClassPath$JarLoader.getManifest(URLClassPath.java:870)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:788)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:415)
at java.base/sun.launcher.LauncherHelper.loadMainClass(LauncherHelper.java:760)
at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:655)
我的样本在这里:
https://github.com/prsolucoes/jrprintpreview
并且您可以在终端中使用命令进行测试:
mvn clean
mvn compile
mvn package
java -jar target/JRPrintPreview-1.0-SNAPSHOT.jar
我下了一个命令来对 jar 进行签名:
mvn jarsigner:sign
但是起不了什么作用(有必要吗?)
我搜索了很多并尝试了删除所有 MANIFEST RSA 和其他签名文件等方法
谁能帮帮我?
谢谢。
我从你的 pom.xml
可以看出你正在使用 maven shade 插件来生成你的 JAR。这基本上会将所有依赖项捆绑到一个(超级)JAR 文件中。优步请查看以下答案,这可能会解决您的问题:
For those who got this error when trying to create an uber-jar with maven-shade-plugin [...]
另请参阅以下关于同一答案的 comment,其中解释了可能的问题:
The signature files are there to indicate that the contents of this jar have these files. When you make an uber jar, you're adding a bunch more files to the jar, and thus the signature is not correct. If you really wanted, you could re-sign the new jar, but of course it would be with your signature, not the old one. Alternatively, you could not distribute the uber jar, but instead include the signed jar as a separate file, but then that defeats the purpose of an uber jar in the first place. – LadyCailin Jan 22 at 12:45
我正在开发 JavaFX 12 示例,但是在生成要执行的 JAR 文件时出现此错误:
java -jar target/JRPrintPreview-1.0-SNAPSHOT.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 java.base/sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:336)
at java.base/sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:269)
at java.base/java.util.jar.JarVerifier.processEntry(JarVerifier.java:316)
at java.base/java.util.jar.JarVerifier.update(JarVerifier.java:230)
at java.base/java.util.jar.JarFile.initializeVerifier(JarFile.java:758)
at java.base/java.util.jar.JarFile.ensureInitialization(JarFile.java:1035)
at java.base/java.util.jar.JavaUtilJarAccessImpl.ensureInitialization(JavaUtilJarAccessImpl.java:69)
at java.base/jdk.internal.loader.URLClassPath$JarLoader.getManifest(URLClassPath.java:870)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:788)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:415)
at java.base/sun.launcher.LauncherHelper.loadMainClass(LauncherHelper.java:760)
at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:655)
我的样本在这里: https://github.com/prsolucoes/jrprintpreview
并且您可以在终端中使用命令进行测试:
mvn clean
mvn compile
mvn package
java -jar target/JRPrintPreview-1.0-SNAPSHOT.jar
我下了一个命令来对 jar 进行签名:
mvn jarsigner:sign
但是起不了什么作用(有必要吗?)
我搜索了很多并尝试了删除所有 MANIFEST RSA 和其他签名文件等方法
谁能帮帮我?
谢谢。
我从你的 pom.xml
可以看出你正在使用 maven shade 插件来生成你的 JAR。这基本上会将所有依赖项捆绑到一个(超级)JAR 文件中。优步请查看以下答案,这可能会解决您的问题:
For those who got this error when trying to create an uber-jar with maven-shade-plugin [...]
另请参阅以下关于同一答案的 comment,其中解释了可能的问题:
The signature files are there to indicate that the contents of this jar have these files. When you make an uber jar, you're adding a bunch more files to the jar, and thus the signature is not correct. If you really wanted, you could re-sign the new jar, but of course it would be with your signature, not the old one. Alternatively, you could not distribute the uber jar, but instead include the signed jar as a separate file, but then that defeats the purpose of an uber jar in the first place. – LadyCailin Jan 22 at 12:45