Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Invalid or corrupt jarfile" when packaging more than 66k files #850

Closed
Rogach opened this issue Aug 20, 2013 · 5 comments
Closed

"Invalid or corrupt jarfile" when packaging more than 66k files #850

Rogach opened this issue Aug 20, 2013 · 5 comments

Comments

@Rogach
Copy link
Contributor

Rogach commented Aug 20, 2013

I stumbled upon following problem: when packaging a project with lots of files, resulting jar file is perceived as corrupt by java runtime.

Steps to reproduce (on java 7, sbt 0.12.3):

$ # in fresh dir
$ echo "object App{}" > Main.scala
$ mkdir -p src/main/resources/
$ # the following is going to take a while :)
$ for i in {1..70000}; do touch src/main/resources/$i; done
$ sbt package
$ java -jar target/scala-2.9.2/default_*.jar
Error: Invalid or corrupt jarfile target/scala-2.9.2/default-92d531_2.9.2-0.1-SNAPSHOT.jar

The probable cause of this problem could be the 65k file limit of the old ZIP format - but java 7 already uses ZIP64 by default, and 7z reports that the resulting jar file is indeed in 64-bit format. (relevant discussion)

The same problem happens with sbt-assembly, by the way (it also uses sbt.Package).

@Rogach
Copy link
Contributor Author

Rogach commented Aug 26, 2013

Seems that it's a problem in a way Java reads jar files on launch - and the fix will only come to us in Java 8.

Meanwhile, there is a simple workaround:

java -jar app.jar
# becomes
java -cp app.jar app.Main

@Rogach Rogach closed this as completed Aug 26, 2013
@harrah
Copy link
Member

harrah commented Aug 26, 2013

Thanks for following up on this.

@ijuma
Copy link
Contributor

ijuma commented Aug 26, 2013

The bug referenced says that the "Fix version" is Java 7 update 40 (out in mid September) so looks like we'll get it sooner than Java 8.

@Rogach
Copy link
Contributor Author

Rogach commented Aug 26, 2013

@ijuma - the resolution on that bug is "Duplicate", the actual entry about backport says "Won't Fix" (and something about that it's "too risky").

@ijuma
Copy link
Contributor

ijuma commented Aug 26, 2013

You are right. My bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants