OneBusAway / onebusaway-gtfs-realtime-from-nextbus-cli

Produce GTFS-realtime data from a NextBus API data source.
Other
16 stars 9 forks source link

"Error: A JNI error has occurred" when running project #6

Closed barbeau closed 9 years ago

barbeau commented 9 years ago

I'm currently seeing this when trying to run the project:

$ 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 d
igest 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)

Also reported on the oba-dev list: https://groups.google.com/forum/#!topic/onebusaway-developers/jSPGZvnfsFk

barbeau commented 9 years ago

Here's the problem/solution: https://bugs.eclipse.org/bugs/show_bug.cgi?id=371954

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.

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

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

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>
gitexperience commented 8 years ago

What if we generate .jar with the gradle ?

barbeau commented 8 years ago

@gitexperience are you still seeing this error with the latest version? It should be fixed in https://github.com/OneBusAway/onebusaway-gtfs-realtime-from-nextbus-cli/commit/c6a82d028bcc08c1f1716dcbc0bc1ea88088d625.

rawadrifai commented 7 years ago

I'm generating the jar file from gradle and seeing the same issue. Did anyone find a resolution?

barbeau commented 7 years ago

@rawadrifai Not sure about Gradle - I'm assuming you'd need to do the equivalent in terms of filtering items out of the JAR as show in https://github.com/OneBusAway/onebusaway-gtfs-realtime-from-nextbus-cli/commit/c6a82d028bcc08c1f1716dcbc0bc1ea88088d625 for Maven.

rawadrifai commented 7 years ago

@barbeau I actually just found a solution. All I needed to do is exclude some files in my jar task:

jar { // other stuff

exclude('META-INF/*.SF')
exclude('META-INF/*.DSA')
exclude('META-INF/*.RSA')

}

barbeau commented 7 years ago

@rawadrifai Great, thanks for sharing! Also - would you be willing to contribute your Gradle build files for this project via a pull request? Apparently you're not the only one that wants to use Gradle to build this project.

rawadrifai commented 7 years ago

I would love to.. but I was actually not building this project. I was searching for a resolution for the issue packaging jar files and not being able to run them later because of signature issues. And I came across this :)

barbeau commented 7 years ago

Ah, gotcha. Thanks.