Skip to content

Extract fails due to a duplicate entry when BOOT-INF/classes contains a directory that's also present in the root of the jar #40903

@snicoll

Description

@snicoll

Building an app with AOT enabled and then using extract leads to the following:

Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:91)
	at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:53)
	at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:58)
Caused by: java.lang.IllegalStateException: java.io.UncheckedIOException: java.util.zip.ZipException: duplicate entry: META-INF/native-image/
	at org.springframework.boot.jarmode.tools.ToolsJarMode.run(ToolsJarMode.java:56)
	at org.springframework.boot.loader.launch.JarModeRunner.main(JarModeRunner.java:43)
	... 7 more
Caused by: java.io.UncheckedIOException: java.util.zip.ZipException: duplicate entry: META-INF/native-image/
	at org.springframework.boot.jarmode.tools.ExtractCommand.run(ExtractCommand.java:118)
	at org.springframework.boot.jarmode.tools.Command.run(Command.java:112)
	at org.springframework.boot.jarmode.tools.Runner.runCommand(Runner.java:68)
	at org.springframework.boot.jarmode.tools.Runner.run(Runner.java:55)
	at org.springframework.boot.jarmode.tools.Runner.run(Runner.java:47)
	at org.springframework.boot.jarmode.tools.ToolsJarMode.run(ToolsJarMode.java:53)
	... 8 more
Caused by: java.util.zip.ZipException: duplicate entry: META-INF/native-image/
	at java.base/java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:244)
	at java.base/java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:115)
	at org.springframework.boot.jarmode.tools.ExtractCommand.lambda$createApplication$3(ExtractCommand.java:258)
	at org.springframework.boot.jarmode.tools.ExtractCommand.withJarEntries(ExtractCommand.java:333)
	at org.springframework.boot.jarmode.tools.ExtractCommand.createApplication(ExtractCommand.java:254)
	at org.springframework.boot.jarmode.tools.ExtractCommand.run(ExtractCommand.java:114)
	... 13 more

This can reproduce build building this sample app with the following command: java -Djarmode=tools -jar build/libs/test-extract-aot-0.0.1-SNAPSHOT.jar extract

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions