Closed refeccd closed 5 months ago
Also I seem to have found a problem in the documentation. If you do a docker multi-stage build as per the docs, shouldn't there be no application.jar in the final ENTRYPOINT?
I can't reproduce the behavior that you have described. The empty spring-boot-loader
directory is to be expected as the loader is not used with the CDS-friendly layout in Spring Boot 3.3. The failure looks to me like the application's dependencies are not in the correct place relative to the application.jar file that refers to them from its Class-Path
manifest entry.
If you do a docker multi-stage build as per the docs, shouldn't there be no application.jar in the final ENTRYPOINT?
No, there should be. It contains the application's own classes and, through its Class-Path
manifest entry, adds all of the application's dependencies to the classpath.
If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.
We were just running into this error too.
After some digging, https://github.com/spring-projects/spring-boot/commit/c22548982abf0b9c5c02406fe789b0423fcfa02d seems to be the breaking change here, as the JarLauncher
was relocated from org.springframework.boot.loader.JarLauncher
to org.springframework.boot.loader.launch.JarLauncher
.
The fix for us was to change the docker entrypoint from
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
to
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
Thanks, @andre161292, but that's not the same problem. The change to the name of the JarLauncher
was made in Spring Boot 3.2. The change described in this issue is specific to Spring Boot 3.3 and its CDS support. You can also see above that the application is being launched using java -jar
where the launcher's class name is not specified.
I'm sorry it was due to my own negligence. I wrongly assumed that the structure after copying was the same as the structure after extracting. So I ignored the part of the dockerfile that was copied from builder, and directly executed application.jar with java -jar, which reported a ClassNotFoundException. I wrote the entire dockerfile in its entirety and it runs fine
Thanks for letting us know.
The empty spring-boot-loader directory is to be expected
Why spring-boot-loader directory is created and mentioned in documentation if it is expected to be empty?
Because it's one of the default layers. Whether or not it has any content depends on the specific type of extraction that you use. This is similar to the snapshot-dependencies
directory which may also be empty if the application does not have any snapshot dependencies.
Thank you for fast response.
Extraction with option --launcher
created non empty spring-boot-loader directory.
Packing the docker image according to the spring-boot 3.3.0 documentation I find that spring-boot-loader is empty in the extracted directories
This causes an error on startup
I tried the latest Spring-Boo-3.3.1-SNAPSHOT and the error is still there