0

I'm trying to build a 6GB size .JAR archive but it won't work. It seems like there is a limit of 4GB for a file since building is successful if I reduce my files to 4GB (4096MB) limit. But I NEED it to be >=6GB and it must contain 25000 files. Please, help me.

Error that I get when trying to start this .jar:

Exception in thread "main" java.lang.IllegalStateException:   java.lang.IndexOutOfBoundsException
    at org.springframework.boot.loader.ExecutableArchiveLauncher.<init>(ExecutableArchiveLauncher.java:43)
    at org.springframework.boot.loader.JarLauncher.<init>(JarLauncher.java:35)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.IndexOutOfBoundsException
    at org.springframework.boot.loader.jar.AsciiBytes.<init>(AsciiBytes.java:69)
    at org.springframework.boot.loader.jar.CentralDirectoryFileHeader.load(CentralDirectoryFileHeader.java:83)
    at org.springframework.boot.loader.jar.CentralDirectoryParser.parseEntries(CentralDirectoryParser.java:68)
    at org.springframework.boot.loader.jar.CentralDirectoryParser.parse(CentralDirectoryParser.java:57)
    at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:118)
    at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:106)
    at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:92)
    at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:83)
    at org.springframework.boot.loader.archive.JarFileArchive.<init>(JarFileArchive.java:61)
    at org.springframework.boot.loader.archive.JarFileArchive.<init>(JarFileArchive.java:57)
    at org.springframework.boot.loader.Launcher.createArchive(Launcher.java:129)
    at org.springframework.boot.loader.ExecutableArchiveLauncher.<init>(ExecutableArchiveLauncher.java:40)
    ... 2 more
Arne Burmeister
  • 20,046
  • 8
  • 53
  • 94

3 Answers3

0

Even if I am really not a fan of supporting such an approach this should work in principle if you use Java 7 and a filesystem/OS that also supports that. Using Java 6 you have no chance but that is EOL anyway. See also What is the maximum number of files per jar?

Community
  • 1
  • 1
Arne Burmeister
  • 20,046
  • 8
  • 53
  • 94
  • But I'm using Java 8! I don't understand. What other approach should I use? I could place resources folder where .jar file is, but don't know how to use it in .jar. – programmer3000 Jan 10 '17 at 17:31
0

Spring boot loader does not support the zip64 format: https://github.com/spring-projects/spring-boot/issues/2895

Restructure your project to package some of your classes into nested jars. If you're using gradle this should be easily achievable with a multi module project.

Strelok
  • 50,229
  • 9
  • 102
  • 115
0

I simply used SpringBoot's addResourceLocations() with a classpath to that .JAR. Simple as that, I used to do this before, I just forgot. Silly me.

  • Can you please give some more details of your solution? I am facing the same issue. – Ajoy Bhatia Jul 12 '18 at 22:04
  • Hi Ajoy. It wasnt smart to try and build a Jar size of 6gb. You will just have to specify the path of your location files somewhere in your project by using addResourceLocations(). It wont be hard, but I am unable to help you further since I dont remember how I did it! – programmer3000 Jul 15 '18 at 08:27
  • My problem is solved, actually. I am experimenting with ways to code a REST API to download large files (~5 GB). I found that a 5 GB file that I use for testing was lying under `src/main/resources`. Removed that, and also some unnecessary dependencies from the POM. That brought down the JAR size, and my test worked. – Ajoy Bhatia Jul 17 '18 at 20:34