Hi Team

I have this project where I have a dependent jar whose size is greater than 2GB. I use the spring-boot-maven plugin to package the application and when starting the application, it immediately fails with the below error. I was able to run the application successfully when this jar was still less than 2Gb but it started failing recently when the size of this jar increased.

Exception in thread "main" java.lang.IllegalStateException: Failed to get nested archive for entry BOOT-INF/lib/pure-model-di-compiled-1.1.20211101.0619.jar
        at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:113)
        at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:87)
        at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:69)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Caused by: java.io.IOException: Unable to open nested jar file 'BOOT-INF/lib/pure-model-di-compiled-1.1.20211101.0619.jar'
        at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:261)
        at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:247)
        at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:109)
        ... 4 more
Caused by: java.io.IOException: Negative seek offset
        at java.io.RandomAccessFile.seek(Unknown Source)
        at org.springframework.boot.loader.data.RandomAccessDataFile$FileAccess.read(RandomAccessDataFile.java:221)
        at org.springframework.boot.loader.data.RandomAccessDataFile$FileAccess.access$400(RandomAccessDataFile.java:205)
        at org.springframework.boot.loader.data.RandomAccessDataFile.read(RandomAccessDataFile.java:117)
        at org.springframework.boot.loader.data.RandomAccessDataFile.read(RandomAccessDataFile.java:102)
        at org.springframework.boot.loader.jar.CentralDirectoryEndRecord$Zip64Locator.<init>(CentralDirectoryEndRecord.java:227)
        at org.springframework.boot.loader.jar.CentralDirectoryEndRecord$Zip64Locator.<init>(CentralDirectoryEndRecord.java:216)
        at org.springframework.boot.loader.jar.CentralDirectoryEndRecord$Zip64End.<init>(CentralDirectoryEndRecord.java:171)
        at org.springframework.boot.loader.jar.CentralDirectoryEndRecord$Zip64End.<init>(CentralDirectoryEndRecord.java:154)
        at org.springframework.boot.loader.jar.CentralDirectoryEndRecord.<init>(CentralDirectoryEndRecord.java:78)
        at org.springframework.boot.loader.jar.CentralDirectoryParser.parse(CentralDirectoryParser.java:51)
        at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:127)
        at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:114)
        at org.springframework.boot.loader.jar.JarFile.createJarFileFromFileEntry(JarFile.java:292)
        at org.springframework.boot.loader.jar.JarFile.createJarFileFromEntry(JarFile.java:269)
        at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:258)
        ... 6 more

Spring Boot Version: 2.2.5-RELEASE

Unfortunately , I'm unable to provide my pom file as this is for an internal project.

I will appreciate any help here.

Thanks.

Comment From: wilkinsona

This may be a duplicate of https://github.com/spring-projects/spring-boot/issues/27822 which was fixed in Spring Boot 2.4.x.

Spring Boot 2.2 is no longer supported. Please upgrade to 2.4.x or later and let us know if it fixes the problem. If it does not, please create a small sample project that reproduces the failure and share it with us by zipping it up and attaching it to this issue or pushing it to a separate GitHub repository.

Comment From: Oluwatobiadeoye

Thanks for you quick response.

You were right. Upgrading the jar to 2.4.11 resolved the issue. At the same time I noticed a more recent version 2.5.4 has the same issue as before.

Comment From: wilkinsona

Thanks. That's interesting. It should work with both 2.4.x and 2.5.x as the same fixes were made in each branch. If you would like us to investigate the problem with 2.5.x, please create and share with us a small sample project that reproduces the failure.

Comment From: Oluwatobiadeoye

Could be because version 2.5.4 was released before this fix was committed. I will see if i can reproduce with a small project.

Comment From: wilkinsona

Yes, you may need 2.5.5 or later as it contains https://github.com/spring-projects/spring-boot/issues/27900.

Comment From: Oluwatobiadeoye

Yeah that makes more sense now. Closing as the issue is resolved