7.3.4. WAR deployment to Tomcat Windows Service

  1. 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'
    }
  2. Run the buildWar gradle task. As a result, app.war and app-core.war files will be generated in the build/distibutions directory of your project.

    gradlew buildWar
  3. Download and run Tomcat 8 Windows Service Installer.

  4. Go to the bin directory of the installed server and run tomcat8w.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.

    tomcatPropeties
  5. Add -Dfile.encoding=UTF-8 to the Java Options field.

  6. Copy the generated app.war and app-core.war files to the webapps directory of the server.

  7. Start the Tomcat service.

  8. Open http://localhost:8080/app in your web browser.