Reputation: 664
I tried following the notes in the grails documentation and attempted to remove the embedded tomcat server when creating a war file for deployment.
However, even though in build.gradle I have :
...
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-autoconfigure"
provided "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
...
The generated WAR file is of the same size as before amending compile
to provided
for org.springframework.boot:spring-boot-starter-tomcat.
While exploring the WAR file I am still seeing the following files:
spring-boot-starter-tomcat-1.2.5.RELEASE.jar tomcat-embed-core-8.0.23.jar tomcat-embed-el-8.0.23.jar tomcat-embed-logging-juli-8.0.23.jar tomcat-embed-websocket-8.0.23.jar
The question is, why is this happening?
Upvotes: 2
Views: 1608
Reputation: 664
OK, it seems to work like this and it would be great if the Grails documentation was a little clearer on what's happening behind the scenes.
Scenario 1 : When creating a (production) war using grails war
and compile "org.springframework.boot:spring-boot-starter-tomcat"
...
Unzipping/exploding the war file, I see Tomcat is embedded within WEB-INF lib folder (5 or more jars) with all the other required application jars and there is also a folder org/springframework containing what looks to be the class files required to launch the embedded Tomcat server.
Scenario 2 : When creating a (production) war using grails war
and provided "org.springframework.boot:spring-boot-starter-tomcat"
...
The 5 or more Tomcat embedded jars are moved out of WEB-INF/lib and placed in WEB-INF/lib-provided. The org/springframework folder and it's contents are not included either.
Testing on a local installation, you can drop this 'scenario 2' version of the war file into the Tomcat web apps directory and the application deploys without a hitch (the lib-provided folder and it's tomcat embed jars presumably being ignored).
Finally, there is a another version of the war file created : appname.war.original
This war doesn't have the WEB-INF/lib-provided nor the org/springframework folder and is smaller in size (of course).
This war also deploys correctly.
Why the tomcat embed jars are included in scenario 2 at all baffles me but there you go....
There is a discussion on it here too :
https://jira.grails.org/browse/GRAILS-12078
In a way, the grails documentation is correct. You remove the embedded tomcat server by adding provided
It just still bundles the jars into a folder named lib-provided
for some reason.
Hope this helps any else pondering the same problem.
Upvotes: 2
Reputation: 431
In build.gradle, add the following:
springBoot {
providedConfiguration = "provided"
}
Honestly, I don't understand the inner workings, but I had the very same problem and this is what provided (no pun intended) the solution.
Upvotes: 1