A template provides configuration information and files to support a feature or application on a tc Runtime instance. The built-in templates that ship with tc Server make it simple to configure tc Runtime features such as SSL or JMX or to add a management application to an instance at creation time, such as Tomcat Manager.

You can create your own templates by creating a subdirectory in the templates directory of your tc Server installation directory and populating it with files according to the instructions in this section. You could, for example, construct a template that allows creating a tc Runtime instance with a web application or set of web applications ready to deploy, with a custom configuration specified at the tcserver create command line or through interactive prompts.

A template is a directory containing files that the tcserver create command processes when it creates a new tc Runtime instance. Some files are copied directly to the new tc Runtime instance. Other files are applied to configuration files in the tc Runtime instance; that is, they are used to alter the content of standard configuration files, such as conf/server.xml.

Files you place in the template directory that are not interpreted specially by the instance creation scripts are copied into the new instance. For example, if your web application requires JAR libraries, you can create a lib subdirectory and place the JAR files there. If you have a WAR file to deploy, put it in a webapps subdirectory and it will be copied to the webapps subdirectory of the new tc Runtime instance.

The target platform (Windows or Unix) and the JVM (Sun HotSpot or IBM J9) are recognized at instance creation time and variables are handled accordingly, files omitted from the copy when appropriate. Your Linux tc Runtime instances will not have unneeded .bat or .dll files. Path names and environment variables are automatically handled with the correct syntax for the target platform.

Parts of a Template

A template directory contains at minimum a README.txt file. The other contents depend on the purpose of the template. The following sections describe the kinds of files that a template can have.



XML Configuration Fragments

Logging Properties Fragment

Modifying Properties Files

Other Files


A template must have a README.txt file in its root directory. This file is a synopsis of the configuration and content that the template provides to an instance. The file should not have the name of the template, but a version and build date are considered best practices. When in doubt, look at the examples provided by the templates packaged in tc Runtime.

When an instance is created, the content of the README.txt files in each template are combined into a single README.txt file that is placed in the root of the created instance. The combined README.txt file documents the templates' contributions to the newly created instance.

Following is the README.txt file that is the result of creating an instance using the base, nio, and nio-ssl templates.

Operating System Family: unix
Virtual Machine Architecture: x64
Virtual Machine Name: hotspot
Template: base
Version: 4.0.0.RELEASE
Build Date: 20180306170814

* Sets Xmx to 512M
* Sets Xss to 256K
* Adds a control script to the instance
* Adds the Windows service wrapper libraries
* Adds a default jmxremote configuration with a read/write user called 'admin'
with a generated password
* Adds a default JULI logging configuration
* Adds a default server configuration containing:
        * A JRE memory leak prevention listener
        * A tc Runtime Deployer listener
        * A JMX socket listener
        * A LockOutRealm to prevent attempts to guess user passwords via a
brute-force attack
        * An in-memory user database
        * A threadpool that has up to 300 threads
        * A host that uses 'webapps' as its app base
        * An AccessLogValve
* Adds a default Tomcat user configuration that is empty
* Adds an init.d script configured to start the instance as a specific user
* Adds a root web application
Template: base-tomcat-7
Version: 4.0.0.RELEASE
Build Date: 20180306170814

* Adds Tomcat 7-specific ThreadLocalLeakPreventionListener
* Adds Tomcat 7-specific catalina.properties
* Adds Tomcat 7-specific default catalina.policy to be used when starting with
the -security option
* Adds Tomcat 7-specific JspServlet configuration
* Adds Tomcat 7-specific web-app declaration
Template: nio-ssl
Version: 4.0.0.RELEASE
Build Date: 20180306170814

* Adds a Non-Blocking IO (NIO) connector for HTTPS
* Adds sample certificate and key files that can be used to test the SSL


A template may contribute a bin/setenv.properties file containing platform-agnostic environmental configuration. This file is turned into bin/setenv.sh on Unix machines and bin/setenv.bat and conf/wrapper.conf files on Windows machines. The file may contain properties with any of the following well-known keys.

Table 1. setenv.properties Keys

Key Description
class.path.# Adds a JAR to the Java class path.
java.library.path.# The path to a native library. It is added to the java.library.path in the JVM command line.
java.opt.# A JVM option to be added to the JVM command line.
jdk.java.options.$ Introduced in 4.0.22 and 4.1.10 this translates to the JDK_JAVA_OPTIONS environment variable.

Each of these keys can be declared multiple times by incrementing its digit suffix. An example declaring two entries for java.library.path follows.


You can specify your own environment variables bin/setenv.properties. Note that you when you define such variables, you must append the variable name with a numeric suffix, for example:


The custom properties convert as MYAPP.OPTIONS="value1 value2" in the CATALINA_BASE/bin/setenv.sh (Unix) or CATALINA_BASE/bin/setenv.bat (Windows) file.

Automatic Boilerplate Decoration

Entries for the setenv.properties keys do not need to have boilerplate text attached. When the template is processed, the values are processed to create command line options with the correct platform- and JVM-specific syntax. The following table describes what will be prepended to each entry.

Table 2. Automatic Boilerplate Decoration
Entry Entry After Decoration
-javaagent:value-1 -javaagent:value-2
-agentpath:value-1 -agentpath:value-2

Memory and Stack Size JAVA_OPTS Filtering

There are a few common properties that are regularly set to control memory and stack size of the VM. In cases where duplicate values for these are found due to the combination of templates, the largest value of each will be chosen. The list of these properties follows.

  • -Xmx
  • -Xms
  • -Xss
  • -XX:MaxPermSize

JVM Type Specific Properties

To ensure that a property is only used for a specific JVM type, the well-known keys can be qualified with values of the vm.name property. The value must be located between the base key and the incrementing digit, delimited by '.' characters. For example:


OS Family Specific Properties

To ensure that a property is only used for a specific operating system family, the well-known keys can be qualified with values of the os.family property. The value must be located between the base key and the incrementing digit, delimited by '.' characters. An example using the os.family property follows.

java.library.path.windows.2=${pivotal.tools.location:C:\Program Files\VMware\VMware Tools}

VM Architecture Specific Properties

To ensure that a property is only used for a specific VM architecture, the well-known keys can be qualified with values of the vm.arch property. The value must be located between the base key and the incrementing digit, delimited by '.' characters. An example using the vm.arch property follows.


Combining Values in Qualified Properties

The well-known keys can be qualified with values of any combination of the implicit properties. These values must be located between the base key and the incrementing digit, delimited by '.' characters, but can be in any order. An example using the os.family, vm.arch, and vm.name properties follows.


XML Configuration Fragments

A template may contribute any of the following XML configuration files.

  • conf/server-fragment.xml
  • conf/web-fragment.xml
  • conf/context-fragment.xml
  • conf/tomcat-users-fragment.xml

These files contribute to the standard Tomcat configuration file of the same name, less the "-fragment" portion of the name. Inside the file is an XML fragment that describes what is to be added, removed, or updated in the respective configuration file. The XML fragment describes its contributions using the add: and remove: keywords on elements and attributes and the update: keyword, which can only be used on attributes. In addition, other XML elements are defined to describe a single XML element that the contributions should act upon. The XML elements that exist can be thought of as a direct example of an XPath expression. For example the XPath expression //Server/Service[@name="Catalina"] would be represented as follows.

<?xml version='1.0' encoding='utf-8'?>
  <Service name="Catalina">

A more complex example of the XPath expression //Server/Service[@name="Catalina"]/Engine[@name="Catalina"][@defaultHost="localhost"] is represented as follows.

<?xml version='1.0' encoding='utf-8'?>
  <Service name="Catalina">
    <Engine name="Catalina" defaultHost="localhost">

Once an element has been specified using an XML fragment, contributions can then be specified. They could be updates and additions of attributes, as illustrated in the following example.

<?xml version='1.0' encoding='utf-8'?>
  <Listener className="com.springsource.tcserver.serviceability.rmi.JmxSocketListener"

When adding an element, once the element has been marked as add:, it is unnecessary to also mark the attributes of the new element. An example of adding an element without marking its attributes follows.

<?xml version='1.0' encoding='utf-8'?>
  <Service name="Catalina">
    <add:Connector executor="tomcatThreadPool"

It is unnecessary to mark any sub-elements with add: when the parent element is marked. An example adding an element with sub-elements without marking its sub-elements follows.

<?xml version='1.0' encoding='utf-8'?>
  <Service name="Catalina">
    <Engine name="Catalina" defaultHost="localhost" add:jvmRoute="${node.name:tc-runtime-1}">
      <add:Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8">
        <Manager className="org.apache.catalina.ha.session.DeltaManager"
        <Channel className="org.apache.catalina.tribes.group.GroupChannel">
          <Membership className="org.apache.catalina.tribes.membership.McastService"
          <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
          <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
            <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
          <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
          <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
        <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>
        <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>
        <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>
        <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>

Specifying the Location of a New Element in an XML Configuration File

When you use a template XML fragment file to add a new element to an XML configuration file, the new element is added to the bottom of the parent element by default. Sometimes, however, you might need to specify an exact location for the new element in the XML file. For example, there are some <Listener> elements that must appear as the first child elements of the root <Server> element at the top of the conf/server.xml file; if they are added to the bottom of the file, the tc Runtime instance will not start.

You specify the exact location of the new element by also including the sibling element that should appear after the new element in the XML fragment file. At instance-creation time when the template is being applied, if the sibling element is found, the new element will be added before it. If, however, the sibling element is not found, the new element will be added at the bottom of its parent element (the default behavior).

For example, assume the original server.xml file, before the template is applied, looks like the following (some elements removed for clarity):

<?xml version="1.0"?>
<Server port="${base.shutdown.port}"
    <Listener className="org.apache.catalina.core.JasperListener"/>
    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>

If you want your template to add a new <Listener> element right before the one with classname org.apache.catalina.core.JreMemoryLeakPreventionListener, create the XML fragment file similar to the following:

<?xml version='1.0' encoding='utf-8'?>
        <add:Listener className="com.springsource.tcserver.properties.SystemProperties"
        <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>

After the template is applied to a new tc Runtime instance, the server.xml file will look like the following:

<?xml version="1.0"?>
<Server port="${base.shutdown.port}"
    <Listener className="org.apache.catalina.core.JasperListener"/>
    <Listener className="com.springsource.tcserver.properties.SystemProperties"
    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>

Logging Properties Fragment

A template may contribute a conf/logging-fragment.properties file. This file contributes to the standard Tomcat conf/logging.properties file. The properties fragment describes its contributions by prefixing property keys with the add. keyword, as shown in the following example.

# Values for com.vmware.jem.level are:

Modifying Properties Files

The following table describes the prefixes that you can add to your custom template to modify the properties files in an instance.

Table 3. Properties File Modification Prefixes
Prefix Description Example Supported in Version
add Adds the property to the properties file. add.my-property=my-value1,my-value2

Adds my-property=my-value1,myvalue2 to the properties file.

append Appends the specified value to the end of the current value of that property. The prefix adds the property if it does not already exist. append.my-property=appended-value

Appends the specified value to the existing my-property property value:


append-delimiter Changes the default delimiter (a comma) to the specified delimiter character. append-delimiter.my-property=;

Changes the delimiter to a semicolon for the my-property=previous-value;appended-value property value

delete Removes the property from the properties file. delete.my-property=

Removes the my-property property from the properties file.

update Replaces the current property value with the specified value. update.my-property=my-new-value

Replaces the current my-property property value with the specified value.


Other Files

Any other file in the template that is not specifically excluded (see Platform Specificity) is copied directly to the instance. Properties files and XML files have their content substituted when copied.

If a file clashes with a file contributed by another template, a warning is displayed to the user and the later file will replace the earlier file. Ordering of template application is dependent on user input and may vary.

Property Substitution

Property substitution allows you to customize tc Runtime instances by providing instance-specific values at creation time. The tcserver script scans for property place holders in files. It substitutes a value that is derived from a default or another defined property, or supplied interactively by the user when the script is run with the --interactive option. Property substitution occurs in the bin/setenv.properties file, the logging properties fragment, all properties files, and XML complete and fragment files.

The syntax for a place holder is as follows:


Implicit Properties

Templates are provided as a set of implicit properties, determined at instance creation time. They are generally specific to the platform where the instance is created and the JAVA_HOME the instance will use at runtime. The list of implicit properties and their possible values are shown in the following table.

Table 4. Implicit Properties
Property Possible Values
  • unix
  • windows
  • x64
  • x86
  • hotspot
  • j9

Configuration Prompts

When a user runs the instance creation script in interactive mode, the script prompts for any property not specified as part of the command. The standard prompt is Please enter a value for '%s'. Default '%s': when a default is provided and Please enter a value for '%s': when no default is provided. These prompts are generic and not good at helping the user select a useful value. You can provide more helpful custom prompt text. To do this, a template must contain a resource bundle called configuration-prompts.properties in the root of the template. This bundle contains the text to display when prompting for a value. In addition, the prompt can include the default value for the property by embedding the ${default} place holder in the text. For example:

pivotal.tools.location=Enter the path to the Pivotal tools installation. The default path is '${default}'\:

The template user accepts the default by pressing Enter without entering a value.

Configuration prompts can be localized for particular languages and countries. To do this, append language and country codes to the file name. For example, a resource bundle containing localized prompts for Spanish speakers would be called configuration-prompts_es.properties.

Platform Specificity

When a tc Runtime instance is created, some files are not created or copied to the instance because they are not required by the target platform. For example, there is no benefit to copying Windows .bat files to a Linux host. In addition, some files are used by the template, or to document the template, and are not copied into the instance.

Files Excluded on Unix

When a template is rendered on a Unix platform, Windows platform-specific files are not rendered in the instance. This includes files matched by the following patterns:

  • **/*.bat
  • **/*.dll
  • **/*.exe
  • **/amd64-winnt/**
  • **/x86-winnt/**
  • **/win32/**
  • **/winx86_64/**

Files Excluded on Windows

When a template is rendered on a Windows platform, Unix platform-specific files are not rendered in the instance. This includes files matched by the following patterns:

  • **/*.sh
  • **/*.so
  • **/amd64-linux/**
  • **/x86-linux/**

Template Files Excluded

Files matching the following patterns are not copied directly into a tc Runtime instance:

  • README.txt
  • bin/setenv.properties
  • conf/*-fragment.properties
  • conf/*-fragment.xml
  • configuration-prompts(_([A-Za-z])+)?.properties

Splitting a Template for Tomcat Versions

The base template is an example of a template that provides different options depending on whether the target instance uses tc Runtime 9 or tc Runtime 10.1. This is a generalized feature that you can use if you have different configuration options or file contributions for tc Runtime 9 or tc Runtime 10.1.

The base template has three parts:

Template Name Description Available Since
base The files in this directory are processed for all tc Runtime instances. 2.0
base-tomcat-9 The files in this directory are processed only if the target instance uses a Tomcat 8.5 runtime. 3.2
base-tomcat-101 The files in this directory are processed only if the target instance uses a Tomcat 10.1 runtime. 3.2

You can create a custom template with different options for tc Runtime 7, tc Runtime 8, and tc Runtime 8.5 by using the same directory naming convention.

Managing Templates

Install a Template Using get-template Command

The get-template command enables a tc Server admin to download and install a template from the tc Server template Repository, a remote location using either the http or https protocol, a local zip file, or directory path.


Execute get-template with the command:

tcserver get-template <name> [OPTIONS]
tcserver list-templates [OPTIONS]

The following options are available:

Table 5. get-template options

Option Description Available Since
-h,--help Prints usage information for get-template. 3.1.0
--overwrite Overwrite the template directory if it already exists. If neither --no-overwrite or --overwrite are specified then it will prompt to overwrite. 3.2.0
-p, --password <password> Password to use with an authenticated URL. If this option is omitted and username is specified then you will be prompted to enter password. 3.1.0
-u, --username <username> Username to use with an authenticated URL. 3.1.0


Listing the contents of the template repository:

tcserver list-templates
Available Templates:

	gemfire-session-manager - Overrides default session manager and stores HTTP sessions in GemFire instance

Retrieve the GemFire session manager template from the template repository:

tcserver get-template gemfire-session-manager

To download and install a template from a web server:

tcserver get-template http://templates.example.com/ default_template.zip --url

To use a file available on the local filesystem:

tcserver get-template /var/templates/default_template.zip --file

To use a directory on the local filesystem:

tcserver get-template /var/templates/default_template --source-directory

Download and Install a Template Package

If you are not able to use the tcserver get-template command, you have another option of downloading the template from the VMware Tanzu Network tc Server download page.

After downloading the template from the VMware Tanzu Network tc Server download page, the template package can be easily extracted into the templates directory located in your tc Server installation directory.


Note: If a previous version of the template already exists, you should backup that template's directories prior to installing the new template.

  1. Download the tc Server template of your choice.
  2. Unzip the package into the <tc Server Installation>/templates directory.
  3. Verify you see the template's name listed in the templates directory.
  4. You can also verify the version of the template by looking in the template's README.txt file.

Step By Step Example

The following example steps show how to create a custom template which adds a property called myproperty to an tc Runtime Instance's conf/catalina.properties file. These steps can be shortened, however, the individual steps are shown to help illustrate the directory layout.

  • In your local template directory create a directory called myproperty

    mkdir myproperty
  • From inside that directory create a directory called conf

    cd myproperty
    mkdir conf
  • Create a file called catalina-fragment.properties and insert myproperty=${myproperty:true} into the file.

    echo 'myproperty=${myproperty:true}' > catalina-fragment.properties
  • Go back to parent directory and create a file called configuration-prompts.properties and insert a descriptive prompts

    cd ..
    echo 'Please provide a value for myproperty' > configuration-prompts.properties

This is all that is needed to create a very basic template. This template can be applied to an tc Runtime Instance or used during creation of the instance.

tcserver create myinstance -t myproperty

The instance will contain a property/value pair of myproperty = true inside the conf/catalina.Properties

The value of myproperty may be changed when the instance is used. Note: That the reason for the double usage of myproperty is because the first usage refers to the name of the template and the second usage refers to the specific property. If the template was named mytemplate and the property was named autoreload then the property would be referred to as mytemplate.autoreload in the next steps.

tcserver create myinstance -t myproperty -p myproperty.myproperty=false

The instance will contain a property/value pair of myproperty = false inside the conf/catalina.Properties

Similarly the property may be specified in a properties file and used with the -f option.

echo 'myproperty.myproperty=false' > myinstance.properties
tcserver create myinstance -t myproperty -f myinstance.properties

The instance will contain a property/value pair of myproperty = false inside the conf/catalina.Properties

check-circle-line exclamation-circle-line close-line
Scroll to top icon