Java War Package Deployment

War Project Identification Strategy

By default, the platform will recognize it as a Java War project based on whether there is a War file in the root directory of the source code.

Platform Compilation and Operation Mechanism

  1. The pre-compilation process will detect whether the startup command configuration file Procfile is defined, and if not defined, the default War package startup configuration file will be generated;
  2. After the pre-compilation processing is completed, the Java-war buildpack will be selected according to the language type to compile the project. The defined JDK version and Web service will be installed during the compilation process;
  3. After the compilation is completed, it will be checked whether the Procfile parameter is set on the platform.

War Project Source Code Specification

In this step, you need to provide a usable Java War source code program for deployment on the Kato platform. This application must at least meet the following conditions:

  1. War package that can run normally locally
  2. The source code program must be hosted on related git or svn services such as gitlab
  3. A War file must exist in the root path of the source code program (that is, the project has been marked as a war file)

Procfile Specification

If the project does not define a Procfile file, the platform will generate a default Procfile to run the War package by default.

web: java $JAVA_OPTS -jar ./webapp-runner.jar --port $PORT ./*.war

The above is the default Procfile, if you need to expand more startup parameters, you can customize the Procfile.

  1. There is a space between web: and java
  2. The end of the file cannot contain special characters
  3. JAVA_OPTS: The platform will automatically set the Xmx and Xms values ​​according to the memory size of the application
  4. PORT: The listening port is determined according to the port set by the user on the platform, the default listening port is 5000

When the web server support is adjusted, the startup command needs to be adjusted to package into War

  • When selecting different versions of tomcat web: java $JAVA_OPTS -jar ./webapp-runner.jar --port $PORT ./*.war
  • When selecting different versions of jetty web: java $JAVA_OPTS -jar ./jetty-runner.jar --port $PORT ./*.war
  • Example web: java $JAVA_OPTS -jar ./webapp-runner.jar --path <path path, example: /r6d> --port $PORT ./*.war

Compile and Run Environment Settings

When choosing the JDK version or other component versions, you need to pay attention to the JDK or other component versions. Do not choose a version that is too high or too low than the version used in the project to avoid source code compilation failure

OpenJDK Support

Currently Kato supports the following versions of OpenJDK:

  • Java 1.6 - 1.6.0_27
  • Java 1.7 - 1.7.0_95
  • Java 1.8 - 1.8.0_74
  • Java 1.9 - 1.9-latest
  • Java 10 - 10.0.2
  • Java 11 - 11.0.1

The default version of the platform uses 1.8. If you need to use another version of OpenJDK, you can specify the required version of the JDK by adding the system.properties file in the source root directory to set the value of java.runtime.version.

# system.properties The current version values ​​that Kato can recognize are 11, 10, 1.9, 1.8, 1.7, 1.6
java.runtime.version=1.8

OracleJDK Support

The platform currently supports OracleJDK, but this feature needs to be enabled in the platform to take effect.

The OracleJDK download is not built-in by default. You need to configure the relevant OracleJDK download address after enabling OracleJDK in the settings.

OracleJDK download address format requirements: http://<web service URL>/jdk-8u201-linux-x64.tar.gz

The configuration priority of the platform settings is higher than the configuration defined in the program code, such as the choice of Java JDK version. In the program code, the JDK version is specified as 1.9 through system.properties, and the JDK version is selected as 11 on the platform. Then by default, the platform-specified version JDK11 will be used first when compiling source code

Web Service Support

Run the war package through the web service (tomcat or jetty), that is, through java -jar ./webapp-runner.jar ./*.war or java -jar ./jetty-runner.jar ./*.war Mode to run.

Currently, you can set the web service version through the build source or define the webserver file in the source root directory

  1. Console build source configuration support version tomcat7, tomcat8, tomcat85, tomcat9, jetty7, jetty9
  2. Define the webserver version in the source root directory
    • webapp-runner-7.0.91.0.jar
    • webapp-runner-8.0.52.0.jar,webapp-runner-8.5.38.0.jar
    • webapp-runner-9.0.16.0.jar
    • jetty-runner-7.5.4.v20111024.jar,jetty-runner-9.4.0.v20161208.jar

The specific correspondence is as follows:

Web service supportWeb service versionCustom jar file name in Procfile
tomcat7webapp-runner-7.0.91.0.jarwebapp-runner.jar
tomcat8webapp-runner-8.0.52.0.jarwebapp-runner.jar
tomcat85 (default)webapp-runner-8.5.38.0.jarwebapp-runner.jar
tomcat9webapp-runner-9.0.16.0.jarwebapp-runner.jar
jetty7jetty-runner-7.5.4.v20111024.jarjetty-runner.jar
jetty9jetty-runner-9.4.0.v20161208.jarjetty-runner.jar

To select the tomcat7 version, you need to pay attention to make sure that the local can be run through java -jar ./webapp-runner-7.0.91.0.jar ./*.war

For detailed configuration of webapp-runner, please refer to webapp-runner instructions

Advanced Build Options

Enable advanced build features in build advanced settings or build sources

Environment VariablesDefault ValueDescription
BUILD_WEBSERVER_URLCustom WEBAPP-RUNNER download URL
BUILD_ONLINEKato built-in Webapp-Runner download by default

Other Instructions

By default, the war file will be decompressed to the /app/target/tomcat.<port> directory. Adding configuration files to the war decompression path is not supported, otherwise the application will not start normally

Sample Demo Program

Example https://github.com/gridworkz/java-war-demo