java - "Invalid signature file digest"通过Maven添加Janino包出错

标签 java maven dependencies package janino

我正在尝试通过 Maven 存储库向 Janino 2.7.6 添加依赖项。当我尝试运行该应用程序时,出现此错误:

--- exec-maven-plugin:1.2.1:exec (unpack-dependencies) @ JanineAttemp2 ---

--- exec-maven-plugin:1.2.1:exec (default-cli) @ JanineAttemp2 ---
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:273)
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.URLClassPath$JarLoader$2.getInputStream(URLClassPath.java:776)
at sun.misc.Resource.cachedInputStream(Resource.java:77)
at sun.misc.Resource.getByteBuffer(Resource.java:160)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:442)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)

...

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 3.972s
Finished at: Sun Aug 24 14:41:26 EST 2014
Final Memory: 15M/37M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project JanineAttemp2: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

我没有直接修改pom.xml文件,它包含:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.hills</groupId>
<artifactId>JanineAttemp2</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>JanineAttemp2</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <mainClass>com.hills.janineattemp2.MainApp</mainClass>
</properties>

<organization>
    <!-- Used as the 'Vendor' for JNLP generation -->
    <name>Your Organisation</name>
</organization>

<build>
    <plugins>
        <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>
                        <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
                        <outputDirectory>${project.build.directory}/classes</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <id>unpack-dependencies</id>

                    <phase>package</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                        <executable>${java.home}/../bin/javafxpackager</executable>
                        <arguments>
                            <argument>-createjar</argument>
                            <argument>-nocss2bin</argument>
                            <argument>-appclass</argument>
                            <argument>${mainClass}</argument>
                            <argument>-srcdir</argument>
                            <argument>${project.build.directory}/classes</argument>
                            <argument>-outdir</argument>
                            <argument>${project.build.directory}</argument>
                            <argument>-outfile</argument>
                            <argument>${project.build.finalName}.jar</argument>
                        </arguments>
                    </configuration>
                </execution>
                <execution>
                    <id>default-cli</id>
                    <goals>
                        <goal>exec</goal>                            
                    </goals>
                    <configuration>
                        <executable>${java.home}/bin/java</executable>
                        <commandlineArgs>${runfx.args}</commandlineArgs>
                    </configuration>
                </execution>
            </executions>  
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArguments>
                    <bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.16</version>
            <configuration>
                <additionalClasspathElements>
                    <additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement>
                </additionalClasspathElements>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.codehaus.janino</groupId>
        <artifactId>janino</artifactId>
        <version>2.7.6</version>
    </dependency>
</dependencies>
</project>

重新创建的步骤很简单:

  • 全新的 Windows 7 + Netbeans 8 安装
  • 创建 Maven > JavaFX 应用程序项目
  • 右键单击“依赖项”>“添加依赖项”
  • 搜索“janino”并添加 org.codehaus.janino 2.7.6
  • 按F6运行

我之前在另一个包中遇到过这个问题,所以我想知道是不是我的设置有问题?

注意:我尝试了此处概述的解决方案 Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes但还没有让它工作,也找不到关于应该将此 XML 插入何处的文档。

最佳答案

这是由已签名的 jar 引起的。 janino 的 jar 包含 DUMMY.DSA DUMMY.SF,你需要在着色时排除这些文件。

像这样

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1/version>
<executions>
    <execution>
        <phase>package</phase>
        <goals>
            <goal>shade</goal>
        </goals>
        <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>

关于java - "Invalid signature file digest"通过Maven添加Janino包出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25468704/

相关文章:

java - 使用 Google 云端点进行数据传输优化

java - 尽可能将变量定义为 "locally"是否会使实现更快?

java - 使用 axistools-maven-plugin 时禁用附件支持

c# - 我将如何使用 C++/CLI dll 将 native 代码与 C# 中的多个依赖库一起包装?

java - 在 WebLogic Server : 12. 2.1.3.0 中部署应用程序时出现错误,原因是 : java. lang.ClassNotFoundException:WebLogic_12

java - 等待 2 个线程在继续程序之前完成

java - 找不到符号: method ceiling(int)

java - 如何让 Jersey 1.9和 Jersey 2共存?

java - 何时使用 maven 依赖管理和依赖

Clojure 传递依赖版本冲突