spring-projects / spring-projects/spring-boot

Allow tools jarmode to run the extract command from an unpacked jar

Open
#43,294 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

If you unpack an uber jar and then run the extract command from jar mode tools, it fails:

$ java -Djarmode=tools org.springframework.boot.loader.launch.JarLauncher extract
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:102)
	at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:64)
	at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:40)
Caused by: java.lang.IllegalStateException: java.lang.IllegalStateException: Manifest attribute 'Spring-Boot-Classpath-Index' is mandatory
	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.lang.IllegalStateException: Manifest attribute 'Spring-Boot-Classpath-Index' is mandatory
	at org.springframework.util.Assert.state(Assert.java:79)
	at org.springframework.boot.jarmode.tools.IndexedJarStructure.getMandatoryAttribute(IndexedJarStructure.java:137)
	at org.springframework.boot.jarmode.tools.IndexedJarStructure.get(IndexedJarStructure.java:145)
	at org.springframework.boot.jarmode.tools.ExtractCommand.getJarStructure(ExtractCommand.java:214)
	at org.springframework.boot.jarmode.tools.ExtractCommand.run(ExtractCommand.java:113)
	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

It would be beneficial for buildpacks if this worked as it would mean that they don't have to zip things back up again.

/cc @anthonydahanne

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with org.springframework.boot.jarmode.tools.ExtractCommand.getJarStructure and IndexedJarStructure.get, then trace how ToolsJarMode invokes the extract command. Reproduce the command against an unpacked uber jar and inspect the existing jar-mode tests, if present. Done means extract works from the unpacked jar without requiring the Spring-Boot-Classpath-Index manifest attribute.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.