We recently upgrade to spring boot 3.2.0-RC1 and the local development does work as expected. Then I wanted to create a docker image, but that does not start, because the Jar is not build correctly to find the main class defined in the loader.properties via loader.main

Just check out the actual main on https://github.com/urlaubsverwaltung/urlaubsverwaltung/ or maybe better the commit 6f53464e3, because I need to revert the upgrade.

Build the application with ./mvnw clean package -DskipTests;

...
[INFO] --- jar:3.3.0:jar (default-jar) @ urlaubsverwaltung ---
[INFO] Building jar: /somedir/urlaubsverwaltung/urlaubsverwaltung/target/urlaubsverwaltung-5.0.0-M4-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot:3.2.0-RC1:repackage (repackage) @ urlaubsverwaltung ---
[INFO] Layout: ZIP
[INFO] Replacing main artifact /somedir/urlaubsverwaltung/urlaubsverwaltung/target/urlaubsverwaltung-5.0.0-M4-SNAPSHOT.jar with repackaged archive, adding nested dependencies in BOOT-INF/.
[INFO] The original artifact has been renamed to /somedir/urlaubsverwaltung/urlaubsverwaltung/target/urlaubsverwaltung-5.0.0-M4-SNAPSHOT.jar.original
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  58.922 s
[INFO] Finished at: 2023-10-26T22:11:44+02:00
[INFO] ------------------------------------------------------------------------

Run the Jar via, command below, and see that the main class is not found.

❯ java -jar target/urlaubsverwaltung-5.0.0-M4-SNAPSHOT.jar
Exception in thread "main" java.lang.ClassNotFoundException: org.synyx.urlaubsverwaltung.UrlaubsverwaltungApplication
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593)
        at org.springframework.boot.loader.net.protocol.jar.JarUrlClassLoader.loadClass(JarUrlClassLoader.java:94)
        at org.springframework.boot.loader.launch.LaunchedClassLoader.loadClass(LaunchedClassLoader.java:91)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:534)
        at java.base/java.lang.Class.forName(Class.java:513)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:88)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:53)
        at org.springframework.boot.loader.launch.PropertiesLauncher.main(PropertiesLauncher.java:563)

The main class is defined in the loader.properties in https://github.com/urlaubsverwaltung/urlaubsverwaltung/blob/main/src/main/resources/loader.properties

and ZIP is defined as layout in https://github.com/urlaubsverwaltung/urlaubsverwaltung/blob/main/pom.xml#L351

Thanks for your work. If this is a false positive and I did miss some migration from 3.1.x to 3.2.x please let me know. If you need more information I am more than happy to provide more.

Comment From: derTobsch

After writing this down and checked the next milestone 3.2.1-RC2 again. I think this is another symptom of #38050

The fallback to the CLASSIC loader implementation does the trick for our project.

      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <layout>ZIP</layout>
          <loaderImplementation>CLASSIC</loaderImplementation>
        </configuration>
      </plugin>

Comment From: scottfrederick

@derTobsch I think this might actually be a duplicate of #37992. Can you test with the latest 3.2.0-SNAPSHOT?

Comment From: derTobsch

@derTobsch I think this might actually be a duplicate of #37992. Can you test with the latest 3.2.0-SNAPSHOT?

@scottfrederick yes, editing our loader.path to loader.path=BOOT-INF/classes/,BOOT-INF/lib/*,./extensions in the loader.properties does work with the new loader implementation. I did not test, if our jars will be picked up under ./extensions. I hope that will work :)

Comment From: derTobsch

@derTobsch I think this might actually be a duplicate of #37992. Can you test with the latest 3.2.0-SNAPSHOT?

@scottfrederick yes, editing our loader.path to loader.path=BOOT-INF/classes/,BOOT-INF/lib/*,./extensions in the loader.properties does work with the new loader implementation. I did not test, if our jars will be picked up under ./extensions. I hope that will work :)

edit: sry, its late. Will also try it with the latest Snapshot and without the additional paths.

Comment From: scottfrederick

I confirmed that the provided app runs when built against the latest 3.2.0-SNAPSHOT without reverting to the CLASSIC loader or configuring the loader path. I'll close this as a duplicate. Thanks for trying the release candidate!