Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

"Invalid or corrupt jarfile" when packaging more than 65k files

622 views
Skip to first unread message

Rogach

unread,
Aug 13, 2013, 12:41:41 PM8/13/13
to simple-b...@googlegroups.com
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)

Should I open a bug at github?

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

Brian KimJohnson

unread,
Feb 14, 2014, 4:18:52 PM2/14/14
to simple-b...@googlegroups.com
Did you find a solution to this problem?  Or did you trim dependencies until you came below the limit?


Thanks

Mariot Chauvin

unread,
Mar 19, 2014, 12:44:38 PM3/19/14
to simple-b...@googlegroups.com
Hi,

I got the same problem yesterday and after debugging it seems to me the problem is in the openjdk JRE itself.
sbt package uses directly JarOutputStream, and I wrote a small program which exhibits the problem.
I have reported the bug to sun, but did not expect any response.

Hope this help,

Mariot
Reply all
Reply to author
Forward
0 new messages