7.3.4. WAR deployment to Tomcat Windows Service
-
Add the buildWar task to the end of build.gradle:
task buildWar(type: CubaWarBuilding) { appHome = './app_home' singleWar = false includeContextXml = true includeJdbcDriver = true appProperties = ['cuba.automaticDatabaseUpdate': true] }
If the target server parameters differ from what you have on the local Tomcat used for fast deployment, provide appropriate application properties. For example, if the target server runs on port 9999, the task definition should be as follows:
task buildWar(type: CubaWarBuilding) { appHome = './app_home' singleWar = false includeContextXml = true includeJdbcDriver = true appProperties = [ 'cuba.automaticDatabaseUpdate': true, 'cuba.webPort': 9999, 'cuba.connectionUrlList': 'http://localhost:9999/app-core' ] }
You can also specify a different
context.xml
file to setup the connection to the production database, for example:task buildWar(type: CubaWarBuilding) { appHome = './app_home' singleWar = false includeContextXml = true includeJdbcDriver = true appProperties = ['cuba.automaticDatabaseUpdate': true] coreContextXmlPath = 'modules/core/web/META-INF/production-context.xml' }
-
Run the
buildWar
Gradle task. As a result,app.war
andapp-core.war
files will be generated in thebuild/distributions
directory of your project.gradlew buildWar
-
Download and run Tomcat 8 Windows Service Installer.
-
Go to the
bin
directory of the installed server and runtomcat8w.exe
with the administrative rights. Set Maximum memory pool to 1024MB on the Java tab. Then go to the General tab and restart the service. -
Add
-Dfile.encoding=UTF-8
to the Java Options field. -
Copy the generated
app.war
andapp-core.war
files to thewebapps
directory of the server. -
Start the Tomcat service.
-
Open
http://localhost:8080/app
in your web browser.