I’ve run into a an issue with Spring Boot (3.3.0), and Wildfly (29.0.0, and 32.0.0).
I’ve found out that when deploying a SB WAR application in Wildfly server, the WEB-INF/classes/META-INF/MANIFEST.MF
is used to populate class metadata instead of META-INF/MANIFEST.MF
.
META-INF/MANIFEST.MF
is generated by SB Gradle plugins and it is used when executing application standard jar (i.e. java -jar application.war
).
However, I’m missing information whether this is expected behavior (and I should create WEB-INF/classes/META-INF/MANIFEST.MF
or not).
Question: Should the WEB-INF/classes/META-INF/MANIFEST.MF
be used for WAR deployments? Why does the behavior differ between WAR (deployments) and executing JAR applications?
Among other things this issue does impact Spring Boot banner (when printing application version).
The issue can be simulated with a demo from https://start.spring.io/
Spring Boot detects application version from Implementation-Version
and other information from manifest file (used for example to print Spring Boot banner). Internally, it just calls mainApplicationClass.class.getPackage().getImplementationVersion()
(viz. https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Package.html#getImplementationVersion() which is populated from manifest file).
In case of executing the application as JAR (i.e. java -jar application.war
) it reads “correct” manifest file (META-INF/MANIFEST.MF
) from the package where the main class (@SpringBootApplication
) is located.
However, in case WAR when deployed to Wildfly server, the classes are initialized with information from WEB-INF/classes/META-INF/MANIFEST.MF
- META-INF/MANIFEST.MF <-- Used when running as JAR the version is read from here
- WEB-INF/classes
|- com/example/ServletInitializer.class
|- com/example/DemoApplication.class
|- META-INF/MANIFEST.MF <-- Used when deployed as Wildfly, the version of application is taken from here (not generated by SB plugin)
The WEB-INF/classes/META-INF/MANIFEST.MF
is not generated by SB Gradle plugin and is used wen
When WEB-INF/classes/META-INF/MANIFEST.MF
is empty or missing the DemoApplication.class.getPackage().getImplementationVersion()
is null.
Unfortunately, I’ve not found much information about WEB-INF/classes/META-INF/MANIFEST.MF
. Most of the sources do refer to META-INF/MANIFEST.MF
only.