0

I'm trying to build a large Open Source project in Eclipse; it uses Maven so I've installed the various plugins (m2eclipse etc) but I'm a little unfamiliar with this setup.

I can build and run the particular JAR I'm interested in with no issues. However, when the newly built JAR tries to open a large ZIP file, I get this:

Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: invalid CEN header (bad sig
nature)
        at org.opentripplanner.graph_builder.impl.GtfsGraphBuilderImpl.buildGraph(GtfsGraphBuilderImpl.java:17
9)
        at org.opentripplanner.graph_builder.GraphBuilderTask.run(GraphBuilderTask.java:127)
        at org.opentripplanner.graph_builder.GraphBuilderMain.main(GraphBuilderMain.java:51)
Caused by: java.util.zip.ZipException: invalid CEN header (bad signature)
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(Unknown Source)

I did some research and it seems that this error means that java.util.ZipFile can't read the file because it's in ZIP64 format. Apparently this was fixed in Java 1.7, so dutifully I've updated the JDK on OS X, and tried to change the Maven project by right-clicking on it in Eclipse, then altering the Project Facet, which in turns seems to have updated the JRE libraries in that project to 1.7:

enter image description here

However, this doesn't work - I still get the error even having re-built the whole project.

Is it possible that the old java.util.zip is still being pulled in from somewhere? I'm not too familiar with how linking works in Java, can older JDKs be 'embedded' like this within dependencies? Or does the java.util.zip just get used that's on the target machine? (this is definitely JRE 1.7) I know for a fact that the code throwing the exception is actually contained within a separate JAR that's pulled in as a Maven dependency:

enter image description here

Do I need to track down and re-build this external JAR against Java 1.7, is that the issue here? Or is there a concept of a Maven 'parent project' that's regressing my new JRE 1.7 back to 1.6? Sorry if these questions are naive.

I originally thought that it would be as simple as just updated the JRE on the runtime machine, but apparently not. So how do I resolve this error?

Community
  • 1
  • 1
Carlos P
  • 3,928
  • 2
  • 34
  • 50
  • When using Eclipse you must explicitly tell it to use another JRE than the one it uses itself. This one is running with Apple Java 6. Newer Eclipses require Oracle Java which automatically fixes the problem. – Thorbjørn Ravn Andersen Dec 12 '16 at 14:30

3 Answers3

2

Assuming that the problem is really caused by using an older version of Java, then rebuilding is not going to make any difference. The real problem is that your application JAR is running on an older JRE.

In the command shell you are using to run your application, run java -version. That will tell you what JDK / JRE will be used when you then run java -jar yourApp.jar ...

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • Thanks Stephen, that answers the question properly - I had wondered if this was the case. This indicates `Java(TM) SE Runtime Environment (build 1.7.0_17-b02)` so I guess there's something else blocking it from supporting ZIP64 - I'll raise a new SO question on it. – Carlos P Apr 16 '13 at 13:08
  • The other possibility is that the ZIP file is broken. Have you tried opening it using other utilities? – Stephen C Apr 16 '13 at 13:26
  • It seems to be fine, but it does contain some pretty massive files. Tried generating it with both WinRAR and also the native Windows explorer shortcut. – Carlos P Apr 16 '13 at 13:50
  • Now I'm not so sure - same error running the JAR on Ubuntu with latest JRE 7 installed, something weird is definitely going on here... – Carlos P Apr 16 '13 at 14:17
0

The most important point in relationship with maven is bear in mind that the source of the truth is the pom file in Maven and NOT the IDE anymore. So changing the compiler version must be done in the pom.xml file and NOT in the IDE.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
0

Maven ignores what JRE are you using in eclipse, you have to force it with the maven compile plugin config. Here is how in this link http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html But with version 1.7 instead of 1.3

Rubén
  • 524
  • 5
  • 22
  • Thanks - will doing this also update the JRE used for the various external JARs or do those all need to be tracked down and re-built too? i.e. does 'java.util.zip' get built into those other JARs, or does it just get linked in at build time. (or even run time?) – Carlos P Apr 16 '13 at 12:52
  • @CarlosP It's just linked from the libraries of the JDK/JRE you are using. Also be sure your JDK at JAVA_HOME is JDK 7 because that's what Maven is going to use – Rubén Apr 16 '13 at 13:00