带有Jetty和Maven Shade插件的清单主要属性的无效签名文件摘要 [英] Invalid signature file digest for Manifest main attributes w/ Jetty and Maven Shade Plugin

查看:89
本文介绍了带有Jetty和Maven Shade插件的清单主要属性的无效签名文件摘要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于此主题,我还看到了其他一些SO Q& As,但到目前为止,没有一种解决方案对我有用:

I've seen a few other SO Q&As on this topic, but so far none of the solutions have worked for me:

  • "Invalid signature file" when attempting to run a .jar
  • Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
  • Valid JAR signature for JavaFX projects

我们将Jetty连同Maven Shade插件一起用于开放源代码应用程序:

We're using Jetty for an open-source application, along with the Maven Shade Plugin:

https://github.com/OneBusAway/onebusaway-gtfs -realtime-from-nextbus-cli

我们开始在构建中遇到以下错误:

We started getting the following error in builds:

$ java -jar onebusaway-gtfs-realtime-from-nextbus-cli.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(Unknown Source)
    at sun.security.util.SignatureFileVerifier.process(Unknown Source)
    at java.util.jar.JarVerifier.processEntry(Unknown Source)
    at java.util.jar.JarVerifier.update(Unknown Source)
    at java.util.jar.JarFile.initializeVerifier(Unknown Source)
    at java.util.jar.JarFile.getInputStream(Unknown Source)
    at sun.misc.URLClassPath$JarLoader$2.getInputStream(Unknown Source)
    at sun.misc.Resource.cachedInputStream(Unknown Source)
    at sun.misc.Resource.getByteBuffer(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

这是我们的问题跟踪器上的问题:

Here's the issue on our issue tracker:

https://github.com/OneBusAway /onebusaway-gtfs-realtime-from-nextbus-cli/issues/6

推荐答案

这似乎是Jetty中的错误:

Looks like this is a bug in Jetty:

https://bugs.eclipse.org/bugs/show_bug.cgi? id = 371954

来自上述错误报告:

jetty-7.6.1.v20120215所依赖的javax.servlet-2.5.0.v201103041518.jar打包存在问题:在javax.servlet jar的META-INF目录中找到文件ECLIPSEF.RSA和ECLIPSEF.SF.

There is an issue with javax.servlet-2.5.0.v201103041518.jar packaging on which jetty-7.6.1.v20120215 depends: in the META-INF directory of the javax.servlet jar are found files ECLIPSEF.RSA and ECLIPSEF.SF.

如果使用使用码头的maven生成jar,则会在最终jar的META-INF目录中获得这2个文件,并且如果运行它,则会得到异常:

If you generate a jar with maven that uses jetty, you get those 2 files in the META-INF directory of the final jar, and if you run it you get an Exception:

java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

解决方法是从生成的jar中排除2个有问题的文件.

The fix is to exclude the 2 offending files from the generated jars.

可以通过将maven-shade-plugin添加到POM中来排除不需要的文件:

The unwanted files can be excluded with the maven-shade-plugin adding to a POM:

<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-shade-plugin</artifactId>
 <version>1.4</version>
 <executions>
  <execution>
   <goals>
    <goal>shade</goal>
   </goals>
   <configuration>
     <filters>
    <filter>
          <artifact>org.eclipse.jetty.orbit:javax.servlet</artifact>
        <excludes>
          <exclude>META-INF/ECLIPSEF.RSA</exclude>
              <exclude>META-INF/ECLIPSEF.SF</exclude>
              <exclude>META-INF/eclipse.inf</exclude>
        </excludes>
        </filter>
       </filters>
    </configuration>
   </execution>
  </executions>
</plugin>

添加:

<filters>
    <filter>
        <artifact>org.eclipse.jetty.orbit:javax.servlet</artifact>
            <excludes>
                <exclude>META-INF/ECLIPSEF.RSA</exclude>
                <exclude>META-INF/ECLIPSEF.SF</exclude>
                <exclude>META-INF/eclipse.inf</exclude>
            </excludes>
    </filter>
</filters>

...到我们的pom.xml为我们工作了.

... to our pom.xml worked for us.

这篇关于带有Jetty和Maven Shade插件的清单主要属性的无效签名文件摘要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆