We tried to update a nested jar file inside a jar file and we see the following exception when we execute our java program residing in the jar file:
Exception in thread "main" java.lang.IllegalStateException: Failed to get nested archive for entry BOOT-INF/lib/spin-sdk-0-SNAPSHOT.jar
at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:109)
at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:87)
at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:72)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:49)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.io.IOException: Unable to open nested jar file 'BOOT-INF/lib/spin-sdk-0-SNAPSHOT.jar'
at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:252)
at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:237)
at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:104)
... 4 more
Turns out that we cannot update the nested jar file using the linux’s zip program. We must extract all files in the jar, then put in the nested jar file together with the extracted files in the same directory, and finally create the jar again with the jar application.
Example execution (replace yourjar.jar with the name of your container jar file that will contain the nested jar file)
jar -xvf yourjar.jar
# put your nested jar here
jar -cfM0 yourjar.jar ./