5.3.8. Deployment to Jelastic Cloud

Below is an example of building and deployment application to the Jelastic cloud.

Please note that only projects using PostgreSQL or HSQL databases are currently supported.

  1. First, create a free test account in the Jelastic cloud using a web browser.

  2. Create a new environment where the application WAR will be deployed:

    • Click New Environment.

      jelasticEnvironment
    • Specify the settings in the window that appears: a compatible environment should have Java 8, Tomcat 8 and PostgreSQL 9.1+ (if the project uses PostgreSQL database). In the Environment Name field, specify a unique environment name and click Create.

    • If the created environment uses PostgreSQL, you will receive an email with the database connection details. Go to the database administration web interface using the link in the email received after the creation of the environment and create an empty database. The database name should be specified later in the custom context.xml.

  3. Build Single WAR file using CUBA Studio:

    • Select CUBA > Deployment > WAR Settings in the main menu.

    • Select Build WAR checkbox.

    • Enter .. in the Application home directory field.

    • Select Include JDBC driver and Include Tomcat’s context.xml checkboxes.

    • If your project uses PostgreSQL, press Generate button next to the Custom context.xml path field. Specify the database user, password, host, and name of the database that you created earlier in the Jelastic web interface.

      customContextXml
    • Select Single WAR for Middleware and Web Client checkbox.

    • Press Generate button next to the Custom web.xml path field. Studio will generate a special web.xml of the single WAR comprising the Middleware and Web Client application blocks.

      jelasticWarSettings
    • Add cuba.logDir property in the App properties field:

      appProperties = ['cuba.automaticDatabaseUpdate': true,
      'cuba.logDir': '${catalina.base}/logs']
    • Click the OK button. Studio adds the buildWar task to the build.gradle file.

      task buildWar(type: CubaWarBuilding) {
          includeJdbcDriver = true
          includeContextXml = true
          appProperties = ['cuba.automaticDatabaseUpdate': true,
                           'cuba.logDir'                 : '${catalina.base}/logs']
          webXmlPath = 'modules/web/web/WEB-INF/single-war-web.xml'
          appHome = '..'
          coreContextXmlPath = 'modules/core/web/META-INF/war-context.xml'
      }
    • If your project uses HSQLDB, open the buildWar task in the build.gradle and add the hsqlInProcess = true property in order to run the embedded HSQL server while deploying the WAR file. Make sure that the coreContextXmlPath property is not set.

      task buildWar(type: CubaWarBuilding) {
          appProperties = ['cuba.automaticDatabaseUpdate': true, 'cuba.logDir': '${catalina.base}/logs']
          appHome = '..'
          includeContextXml = true
          webXmlPath = 'modules/web/web/WEB-INF/single-war-web.xml'
          includeJdbcDriver = true
          hsqlInProcess = true
      }
    • Start build process by running buildWar from the command line:

      gradlew buildWar

      As a result, the app.war file will be created in the build\distributions\war project subdirectory.

  4. Use deployWar Gradle task to deploy your WAR file to Jelastic.

    task deployWar(type: CubaJelasticDeploy, dependsOn: buildWar){
        email = ****
        password = ****
        hostUrl = 'app.j.layershift.co.uk'
        environment = 'my-env-1'
    }
  5. After the deployment process is completed, your application will be available in the Jelastic cloud. To open it, use a URL like <environment>.<hostUrl> in the browser.

    For example:

    http://my-env-1.j.layershift.co.uk

    You can also open the application using the Open in Browser button located on the environments panel in Jelastic.

    jelasticDeploy