我已经看过其他一些SO Q& As这个主题,但到目前为止,没有一个解决方案对我有用:
我们使用Jetty作为开源应用程序,以及Maven Shade插件:
https://github.com/OneBusAway/onebusaway-gtfs-realtime-from-nextbus-cli
我们开始在构建中收到以下错误:
$ 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)
以下是我们的问题跟踪器上的问题:
https://github.com/OneBusAway/onebusaway-gtfs-realtime-from-nextbus-cli/issues/6
答案 0 :(得分:2)
看起来这是Jetty中的一个错误:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=371954
从上面的错误报告:
javax.servlet-2.5.0.v201103041518.jar包装有一个问题,其中jetty-7.6.1.v20120215依赖于:在javax.servlet jar的META-INF目录中找到文件ECLIPSEF.RSA和ECLIPSEF.SF。
如果你生成一个带有使用jetty的maven的jar,你可以在最后一个jar的META-INF目录中获得这两个文件,如果你运行它就会得到一个异常:
java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
修复方法是从生成的jar中排除2个违规文件。
可以使用添加到POM的maven-shade-plugin排除不需要的文件:
<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
为我们工作。