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

CDS extract fails if application has its own META-INF directory #40947

Closed
sgrimm opened this issue May 29, 2024 · 3 comments
Closed

CDS extract fails if application has its own META-INF directory #40947

sgrimm opened this issue May 29, 2024 · 3 comments
Labels
status: duplicate A duplicate of another issue

Comments

@sgrimm
Copy link

sgrimm commented May 29, 2024

Tried using the new -Djarmode=tools mode with Spring Boot 3.3.0 on my application and the extraction failed (stack trace below). It turns out to be because my application has a META-INF directory with a service configuration. If I remove my src/main/resources/META-INF directory and build the fat jar again, the extraction succeeds.

Repo: https://github.com/terraware/terraware-server

What I ran:

./gradlew bootJar
cd build/libs
java -Djarmode=tools -jar terraware-server-*.jar extract

Stack trace:

Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	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/services/
	at org.springframework.boot.jarmode.tools.ToolsJarMode.run(ToolsJarMode.java:56)
	at org.springframework.boot.loader.launch.JarModeRunner.main(JarModeRunner.java:43)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	... 4 more
Caused by: java.io.UncheckedIOException: java.util.zip.ZipException: duplicate entry: META-INF/services/
	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)
	... 6 more
Caused by: java.util.zip.ZipException: duplicate entry: META-INF/services/
	at java.base/java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:259)
	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)
	... 11 more

Relevant contents of jarfile (unzip -l terraware-server-*.jar | grep META-INF):

        0  05-29-2024 17:29   META-INF/
      441  05-29-2024 17:29   META-INF/MANIFEST.MF
        0  02-01-1980 00:00   META-INF/services/
       66  02-01-1980 00:00   META-INF/services/java.nio.file.spi.FileSystemProvider
        0  05-29-2024 17:29   BOOT-INF/classes/META-INF/
     2884  05-29-2024 17:29   BOOT-INF/classes/META-INF/terraware-server.kotlin_module
        0  05-29-2024 17:29   BOOT-INF/classes/META-INF/services/
       70  05-29-2024 17:29   BOOT-INF/classes/META-INF/services/java.text.spi.DecimalFormatSymbolsProvider
        0  05-29-2024 10:29   META-INF/BOOT.SF
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 29, 2024
@scottfrederick
Copy link
Contributor

Duplicates #40903. Can you try with the latest 3.3.1-SNAPSHOT build?

@scottfrederick scottfrederick closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2024
@scottfrederick scottfrederick added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels May 29, 2024
@sgrimm
Copy link
Author

sgrimm commented May 29, 2024

Ah, thanks, overlooked that issue because I wasn't doing an AOT build. Can confirm that the problem is fixed in 3.3.1-SNAPSHOT.

@wilkinsona
Copy link
Member

I've updated the title of #40903 to reflect the broader nature of the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants