I am implementing a war file which should support execution in two different ways:
- Inside Servlet Container - by deploying it in Tomcat or Jetty.
- Outside Servlet Container - executing it from command prompt and not using any embedded servlet container. This is required to be supported as part of the war file.
I found Spring Boot Loader component more relevant for fulfilling #2. I tried using it manually before integrating it with Maven. I followed the section - 'WAR file structure' as mentioned as per this documentation. Refer to section 'WAR file structure'.
I followed the following steps. I created the war file. I unzipped it and then added all the spring boot loader class files at its root. I added appropriate entries to the manifest file for making the war executable. Then zipped it and renamed back it back to the original war file. When I executed it with command - Java -jar mywar.war, it failed with the following exception:
java.lang.IllegalStateException: Unable to open nested compressed entry WEB-INF/lib/spring-core-3.1.2.RELEASE.jar at org.springframework.boot.loader.jar.JarFile.getNestedJarFileFromFileEntry(JarFile.java:330) at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:305) at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:87) at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:74) at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:78) at org.springframework.boot.loader.Launcher.launch(Launcher.java:52) at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:79)
It is giving error not only for specific jar but for all jar files. I guess, it will also fail when I automate the above steps with Maven.