Skip to content

Legacy application

This tutorial focuses on creating example legacy application with Tomcat. If you want to know more details about creating and starting applications, click here.

Click here to download example legacy application.

Creating application package

Let's create our directory structure. It should look like this:

├── bin
└── conf
    └── conf.yml

Now you can go and download Tomcat. You can download it here. Then, untar tomcat files to bin directory. Full directory structure should look like this:

├── bin
│   ├── bin
│   ├── BUILDING.txt
│   ├── conf
│   ├──
│   ├── lib
│   ├── LICENSE
│   ├── logs
│   ├── NOTICE
│   ├──
│   ├── RUNNING.txt
│   ├── temp
│   ├── webapps
│   └── work
└── conf
    └── conf.yml

You need to modify bin/conf/server.xml file. Here is the content of file:

<?xml version="1.0" encoding="UTF-8"?>
<Server port="${ont_port_1}" shutdown="SHUTDOWN">
    <Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
    <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on"/>
    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
    <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
        <Resource name="UserDatabase" auth="Container"
                  description="User database that can be updated and saved"
    <Service name="Catalina">
        <Connector port="${ont_port_2}" protocol="HTTP/1.1"
        <Engine name="Catalina" defaultHost="localhost">
            <Realm className="org.apache.catalina.realm.LockOutRealm">
                <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
            <Host name="localhost" appBase="webapps"
                  unpackWARs="true" autoDeploy="true">
                <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                       prefix="localhost_access_log" suffix=".txt"
                       pattern="%h %l %u %t &quot;%r&quot; %s %b"/>


It should contain placeholders with ports (e.g. ${ont_port_1}) that will be replaced.

Now you need to write configuration to conf/conf.yml file. Configuration file should look like this.

  name: 'tomcat'
  version: '1.0.0'
  appType: 'standard'
  procType: 'native'
    name: 'GenericOsProcessProviderImpl'
    version: '1.0.0'
        command: '${ont_app_path}/bin/bin/'
        successLine: 'Tomcat started'
        command: '${ont_app_path}/bin/bin/'
    name: 'PlaceHolderManagerImpl'
    version: '1.0.0'
      - '${ont_app_path}/bin/conf/server.xml'
    healthCheckUrl: 'http://${address}:${ont_port_2}'
      - entity:
          priority: 1
          port: ${ont_port_2}
            type: 'HTTP'
            version: '2.0'
          isExternal: true
          isInternal: true

As you can see, file with placeholders was provided in filesToReplace property.

Now you can tar your files. Final structure:

├── bin
│   ├── bin
│   ├── BUILDING.txt
│   ├── conf
│   ├──
│   ├── lib
│   ├── LICENSE
│   ├── logs
│   ├── NOTICE
│   ├──
│   ├── RUNNING.txt
│   ├── temp
│   ├── webapps
│   └── work
└── conf
    └── conf.yml

To simply create an archive on Linux run command tar -czvf <your_archive_name>.tar.gz bin/ conf/ from the directory where you created directories bin and conf. It is important as archive keeps the structure of relative paths.

Upload and start

Now you should be ready to upload and start Tomcat application.

# Upload app
$ onteoncli application list
id createdAt updatedAt name version type processType

$ onteoncli application-registry upload tomcat.tar.gz 
Starting upload session...
Sending part no 0...
Sending part no 1...
Sending part no 2...
Finishing upload session...
uploaded: true

$ onteoncli application list
id                       createdAt               updatedAt               name   version type     processType
616c2e4e3f9ae8684a3e00c3 2021-10-17T14:08:14.84Z 2021-10-17T14:08:14.84Z tomcat 1.0.0   standard native

# Create instance
$ onteoncli node list
id                       createdAt                updatedAt                ipAddress  nodeApiPort zoneId status
5e04ca80e2f8afd6e15abccf 2021-10-17T13:46:51.288Z 2021-10-17T14:09:30.567Z 8030        null   available
12c0ab38bfaee58dc01b7d65 2021-10-17T13:46:51.288Z 2021-10-17T14:09:31.106Z 8030        null   available

$ onteoncli application-instance create 616c2e4e3f9ae8684a3e00c3 5e04ca80e2f8afd6e15abccf
id:                 74de0c3641c120972bc53d3f
createdAt:          2021-10-17T14:10:18.084Z
applicationName:    tomcat
applicationVersion: 1.0.0
applicationId:      616c2e4e3f9ae8684a3e00c3
nodeId:             5e04ca80e2f8afd6e15abccf
status:             created

$ onteoncli application-instance list
id                       createdAt                applicationName applicationVersion applicationId            nodeId                   status
74de0c3641c120972bc53d3f 2021-10-17T14:10:18.084Z tomcat          1.0.0              616c2e4e3f9ae8684a3e00c3 5e04ca80e2f8afd6e15abccf created
e4d6b06f2d34607650dff98d 2021-10-17T13:46:48.742Z nginx-edge      1.0.0              null                     12c0ab38bfaee58dc01b7d65 running
bc7e4e809fdf2fcca2699be2 2021-10-17T13:46:48.741Z nginx-edge      1.0.0              null                     5e04ca80e2f8afd6e15abccf running
e46fa72820a6618d90db7dbd 2021-10-17T13:46:47.568Z nginx-inner     1.0.0              null                     12c0ab38bfaee58dc01b7d65 running
b459449f5b82c2d4ad7b42fa 2021-10-17T13:46:47.564Z nginx-inner     1.0.0              null                     5e04ca80e2f8afd6e15abccf running

# Start instance
onteoncli application-instance start 74de0c3641c120972bc53d3f

You can access Tomcat at http://localhost:8020/_by_name/tomcat/ or http://localhost:8020/_by_name_and_version/tomcat/1.0.0/.