If you use WAR files to deploy applications, you can configure custom Java Tomcat parameters. For example, you can configure custom application ports, application access paths, and maximum number of threads. This topic describes how to configure and modify Java Tomcat parameters in the SAE console.

Prerequisites

The Application Deployment Method parameter is set to Deployment with WAR Packages.

Procedure

Configure Java Tomcat when you create applications

  1. Log on to the SAE console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click Create Application.
  3. In the Basic Information step, configure the parameters and click Next: Application Deployment Configurations.
  4. In the Deployment Configurations step, configure the Technology Stack Programming Language and Application Deployment Method parameters and the corresponding settings.
  5. In the Java Tomcat Settings section, select Custom Configuration and click Edit.
    Figure - Java Tomcat Settings
  6. In the Edit Java Tomcat Configuration panel, configure the parameters and click OK.
    Figure - Edit Java Tomcat configuration
    ParameterDescription
    Application PortThe port number used by the application. Valid values: 1024 to 49151. Default value: 8080.
    Tomcat ContextThe application access path. Valid values:
    • Package Name: The name of the WAR file is used. You do not need to configure this parameter. This setting is supported only if you set the File Upload Method parameter to Upload WAR Package.
    • Root Directory: The application access path is /.
    • Custom: Specify an application access path in the Custom Path field.
    Maximum ThreadsThe maximum number of threads that concurrently process requests. Valid values: 10 to 1024. Default value: 400.
    Important The value of the Maximum Threads parameter affects the application performance. Exercise caution when you configure this parameter.
    Tomcat EncodingThe encoding format for Tomcat. Valid values: UTF-8, ISO-8859-1, GBK, and GB2312. Default value: ISO-8859-1.
    Use Body Encoding for URLBy default, this feature is enabled. In this case, you can use the character set of the HTTP request body to decode query parameters (QueryString).
  7. Click Next: Confirm Specifications.
  8. In the Specification Confirmation step, view the details of the application and the fee for the selected specifications. Then, click Confirm.
    The Creation Completed step appears. You can click Application Details to go to the Basic Information page of the application.
  9. Check whether the configurations have taken effect.
    • Method 1:

      In the left-side navigation pane of the Basic Information page, click Change Records. On the Change Records page, view the change details. If Executed is displayed in the Change Status column, the application is deployed and the configurations have taken effect.

    • Method 2:

      On the Basic Information page, click the Instance Deployment Information tab to view the Status of the instances. If Running is displayed in the Status column, the application is deployed and the configurations have taken effect.

Configure Java Tomcat when you deploy applications

Warning After you redeploy an application, the application is restarted. To prevent unpredictable errors such as business interruptions, we recommend that you deploy applications during off-peak hours.

The procedure that can be performed to update an application varies based on the number of instances in the application. This section provides an example on how to configure the required features for an application in which the number of instances is greater than or equal to 1. For information about how to update an application in which the number of instances is 0, see Update an application.

  1. Log on to the SAE console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click the name of an application.
  3. In the upper-right corner of the Basic Information page, click Deploy Application.
  4. In the Java Tomcat Settings section, select Custom Configuration and click Edit.
    Figure - Java Tomcat Settings
  5. In the Edit Java Tomcat Configuration panel, configure the parameters and click OK.
    Figure - Edit Java Tomcat configuration
    ParameterDescription
    Application PortThe port number used by the application. Valid values: 1024 to 49151. Default value: 8080.
    Tomcat ContextThe application access path. Valid values:
    • Package Name: The name of the WAR file is used. You do not need to configure this parameter. This setting is supported only if you set the File Upload Method parameter to Upload WAR Package.
    • Root Directory: The application access path is /.
    • Custom: Specify an application access path in the Custom Path field.
    Maximum ThreadsThe maximum number of threads that concurrently process requests. Valid values: 10 to 1024. Default value: 400.
    Important The value of the Maximum Threads parameter affects the application performance. Exercise caution when you configure this parameter.
    Tomcat EncodingThe encoding format for Tomcat. Valid values: UTF-8, ISO-8859-1, GBK, and GB2312. Default value: ISO-8859-1.
    Use Body Encoding for URLBy default, this feature is enabled. In this case, you can use the character set of the HTTP request body to decode query parameters (QueryString).
  6. After you configure the settings, click Confirm.

Modify a Java Tomcat configuration file by using a ConfigMap

If the preceding Java Tomcat parameters provided in the SAE console cannot meet your business requirements, or if you want to modify your Java Tomcat configuration file, you can create a ConfigMap.

After you deploy your application in SAE by using a WAR file, the server.xml file is saved in the /home/admin/apache-tomcat-8.5.42/conf directory. In this section, the server.xml file is used as an example to describe how to modify a Java Tomcat configuration file by using a ConfigMap.

  1. Modify the server.xml file.
    1. Log on to the SAE console.
    2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click the name of an application.
    3. On the Basic Information page, click the Instance Deployment Information tab. In the Default Group section, click Webshell in the Actions column of the application.
    4. In the Webshell window, modify the content of the server.xml file and close the window.
      1. Run the following command to go to the directory where the server.xml file is saved.
        cd /home/admin/apache-tomcat-8.5.42/conf
      2. Run the following command to view the content of the server.xml file.
        cat server.xml
      3. Copy the content of the server.xml file to your on-premises computer, modify the content of the file based on your business requirements, and then copy the new content.
  2. Create a ConfigMap.
    Note The namespace of a ConfigMap that you want to create must be the same as the namespace of the application for which you want to create the ConfigMap.
    1. On the Basic Information page of the current application, click the Back icon in the upper-left corner to go to the Applications page.
    2. In the left-side navigation pane, click Namespaces. In the top navigation bar, select a region. Then, click the name of a namespace.
    3. In the left-side navigation pane, click ConfigMaps. On the ConfigMaps page, click Create.
    4. In the Create ConfigMap panel, configure the parameters. Copy the new content of the server.xml file to the Configuration Content field and click OK.
      In this example, the Method parameter is set to Manual. The following table describes the parameters. For more information, see Manage a Kubernetes ConfigMap.
      ParameterDescription
      ConfigMap NameEnter a custom name.
      ConfigMap DescriptionEnter a custom description.
      Configure Mappings
      • A key can contain up to 250 characters in length. A value can contain up to 10,000 characters in length.
      • A key can be mapped to multiple values. You can add up to 20 key-value pairs.
      • To add more key-value pairs, click Add.
    After you create a ConfigMap, the ConfigMap is displayed on the ConfigMaps page.
  3. Deploy the application and mount the ConfigMap.
    1. In the left-side navigation pane, click Basic Information. On the Namespace Details page, click the Resource Information tab.
    2. Click the value of Applications. On the Applications page, click the application that you want to deploy.
    3. In the upper-right corner of the Basic Information page, click Deploy Application.
    4. In the lower part of the Deploy Application page, click the ConfigMaps section, select the ConfigMap and the key that are configured in Step2, and then enter a mount path.
    5. After you configure the settings, click Confirm.
      You can go to the Change Records page to check the deployment status of the application.