Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
snicoll opened this issue May 25, 2024 · 4 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented May 25, 2024

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

@snicoll snicoll added the status: waiting-for-triage An issue we've not yet triaged label May 25, 2024
@snicoll snicoll changed the title Extract fails with "duplicate entry: META-INF/native-image/" Extract jar produced by Gradle plugin fails with "duplicate entry: META-INF/native-image/" May 25, 2024
@snicoll
Copy link
Member Author

snicoll commented May 25, 2024

I've updated the demo to add a Maven project. Extracting works as expected so it looks like it's specific to a jar produced by the Gradle plugin.

@mhalbritter mhalbritter self-assigned this May 27, 2024
@mhalbritter mhalbritter added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels May 27, 2024
@mhalbritter mhalbritter added this to the 3.3.x milestone May 27, 2024
@mhalbritter mhalbritter changed the title Extract jar produced by Gradle plugin fails with "duplicate entry: META-INF/native-image/" Extract AOT-processed jar produced by Gradle plugin fails with "duplicate entry: META-INF/native-image/" May 27, 2024
@mhalbritter mhalbritter modified the milestones: 3.3.x, 3.3.1 May 27, 2024
@wilkinsona wilkinsona changed the title Extract AOT-processed jar produced by Gradle plugin fails with "duplicate entry: META-INF/native-image/" Extract fails due to a duplicate entry when BOOT-INF/classes contains a directory that's also present in the root of the jar May 29, 2024
@wilkinsona
Copy link
Member

This also fails with Maven if, for example, you have a META-INF/services/… file in src/main/resources. In this case, which also affects Gradle, AOT isn't required for the problem to occur.

@rogelio-datasite
Copy link

Is there a workaround for this? Or do we need to wait for the 3.3.1 release?

@wilkinsona
Copy link
Member

I'm not aware of a workaround. 3.3.1 will be released on Thursday so not too long to wait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants