Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org.springframework.boot.loader.JarLauncher cannot be found, but org.springframework.boot.loader.launch.JarLauncher can

Trying to deploy a Spring Boot 3.2 app in a layered docker I basically followed this blogpost and specifically, my docker entrypoint was:

ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]

Yet the docker doesn't start and display the usual

Error: Could not find or load main class org.springframework.boot.loader.JarLauncher
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.loader.JarLauncher

After some digging in the initial jar file, I found out that the JarLauncher class is actually under org.springframework.boot.loader.launch.JarLauncher.

and if I replace the entrypoint by this one:

ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]

The app actually starts.

Jumping back in the Spring Doc the package should still be org.springframework.boot.loader.JarLauncher (according to the doc, I mean)

So... has the class JarLauncher been moved, and the documentation is outdated, or is it some mistake in my configuration? Since I can't find any documentation about this change (witch seems to be fairly important)

Of course the usual java -jar command runs correctly since the manifest file is alright.

I double checked by starting a new project with a Spring Boot 2.7, and the JarLauncher class is indeed in the org.springframework.boot.loader package

like image 473
minioim Avatar asked Sep 02 '25 13:09

minioim


2 Answers

You are looking at a blog for Spring 2.3 and are using a non final Spring Boot 3.2.

The classes have moved, see this ticket and the documentation is perfectly fine if you look at the correct one. You looked at the current production version which is 3.1 and not 3.2 as that is still under development.

So in short that blog post is (sort of) outdated, the documentation is perfectly in order as long as you read the proper one.

like image 51
M. Deinum Avatar answered Sep 05 '25 16:09

M. Deinum


This answer may help to solve some people's problem

  • If your project is running correctly, now whether you use IntelliJ or the java -jar command or any other method
  • And you only face this problem when you use Docker
  • Be sure to check the Docker file thoroughly

for example enter image description here

like image 34
Javad Mahdioun Avatar answered Sep 05 '25 15:09

Javad Mahdioun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!