This chapter provides sample instructions for deploying the WAR to Apache Tomcat. See Upgrading for Apache Tomcat Deployments for instructions on updating to a newer version of the SOAtest and Virtualize Server.
The first example outlines the recommended method for deploying a WAR file at the root context of Apache Tomcat. The second example describes a shortcut for an easier (but not recommended) installation method. Using a "non-root" context might not work for some servlet containers.
Apache Tomcat Deployment Example 1 (Recommended Method)
One way to deploy the WAR file with Apache Tomcat at the ROOT context path is as follows:
- Create a new folder to serve as <SOAVIRT_HOME>. It can be located anywhere except within the Apache Tomcat webapps directory. For example, on Windows you might use
c:/wars/soavirt
. - Extract the contents of the WAR file into <SOAVIRT_HOME>.
- Download Apache Tomcat 8.5 or 9.0 for your platform from http://tomcat.apache.org/.
- Extract the downloaded Apache Tomcat to a location of your choice (<TOMCAT_HOME>).
- In
<TOMCAT_HOME>/conf/Catalina/localhost/
, create an empty ROOT.xml file. Open the ROOT.xml file you just created and add a Context element such as the following (making the appropriate adjustments to docBase absolute path as needed, depending on your specific <SOAVIRT_HOME> location):
<Context docBase="c:/wars/soavirt" path="" reloadable="true" />
- (Optional) If you want to deploy the WAR file over HTTPS, perform the following steps to configure for SSL:
Create a keystore file to store the server's private key and self-signed certificate by executing the following command:
<JAVA_HOME>/bin/keytool -genkey -alias tomcat -keyalg RSA -keystore /path/to/soavirt.keystore
- Specify "changeit" for all passwords when prompted. It is recommended for the keystore and <tomcat> alias passwords to be the same.
The
soavirt.keystore
file will be created in the specified directory.Uncomment the SSL HTTP/1.1 Connector entry in the server.xml configuration file in the
<TOMCAT_HOME>/conf/
directoryand update the
keystoreFile
attribute value:<!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 --> <Connector protocol="org.apache.coyote.http11.Http11NioProtocol" port="8443" maxThreads="200" scheme="https" secure="true" SSLEnabled="true" keystoreFile="/path/to/soavirt.keystore" keystorePass="changeit" clientAuth="false" sslProtocol="TLS"/>
- Specify the ports used by Apache Tomcat in the config.properties file in the
<SOAVIRT_HOME>/WEB-INF/
directory (see Server Configuration for details). For example, you might useserver.port.http=8080
orserver.port.https=8443
. The ports specified in config.properties must match the ports specified in the Tomcat configuration. - Specify the appropriate license in the config.properties file in the
<SOAVIRT_HOME>/WEB-INF/
directory (see Server Configuration for details). - Start Tomcat (for example, from
<TOMCAT_HOME>/bin
). Browse to http://localhost:8080/ (adjust the port if needed). The following message confirms that the application was installed correctly:
There are no deployments on this server. Cannot respond to this request: /.
By default, a workspace directory will be created in <SOAVIRT_HOME>.
Apache Tomcat Deployment Example 2 (Shortcut Method)
Although this method is easier than the first, it is not recommended because it removes the default Tomcat ROOT web application.
- Download Apache Tomcat 8.5 or 9.0 for your platform from http://tomcat.apache.org/.
- Extract the downloaded Apache Tomcat to a location of your choice (<TOMCAT_HOME>).
- Remove the “ROOT” folder from the webapps directory.
- Rename the soavirt_<VERSION>.war file to ROOT.war.
- Copy ROOT.war into the
<TOMCAT_HOME>/webapps/
folder. - (Optional) If you want to deploy the WAR file over HTTPS, perform the following steps to configure for SSL:
Create a keystore file to store the server's private key and self-signed certificate by executing the following command:
<JAVA_HOME>/bin/keytool -genkey -alias tomcat -keyalg RSA -keystore /path/to/soavirt.keystore
- Specify "changeit" for all passwords when prompted. It is recommended for the keystore and <tomcat> alias passwords to be the same.
- The soavirt.keystore file will be created in the specified directory.
Uncomment the SSL HTTP/1.1 Connector entry in the server.xml configuration file in the
<TOMCAT_HOME>/conf/
directory and update thekeystoreFile
attribute value:<!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 --> <Connector protocol="org.apache.coyote.http11.Http11NioProtocol" port="8443" maxThreads="200" scheme="https" secure="true" SSLEnabled="true" keystoreFile="/path/to/soavirt.keystore" keystorePass="changeit" clientAuth="false" sslProtocol="TLS"/>
- Edit the existing config.properties file (or create a new file) stored in the
<TOMCAT_HOME>/webapps
folder and add entries for the ports used by Apache Tomcat (see Server Configuration for details). For example, addserver.port.http=8080
orserver.port.https=8443
. The ports specified in config.properties must match the ports specified in the Tomcat configuration. - Specify the appropriate license in the config.properties file in the
<TOMCAT_HOME>/webapps/
directory (see Server Configuration for details). - Start Tomcat (for example, from
<TOMCAT_HOME>/bin
). Browse to http://localhost:8080/ (adjust the port if needed). The following message confirms that the application was installed correctly:
There are no deployments on this server. Cannot respond to this request: /.
By default, a workspace directory will be created in
<TOMCAT_HOME>/webapps/ROOT
.
Additional Tomcat Configurations
Depending on your infrastructure and project requirements, your Tomcat server may require additional configuration.
URI Character Encoding
The SOAtest and Virtualize server supports Tomcat's relaxedPathChars
and relaxedQueryChars
properties. These properties enable you to specify which unencoded characters should be allowed in URI paths and URI query strings. You can specify the following characters: " < > [ \ ] ^ ` { | }
Refer to the Tomcat documentation for additional information: https://tomcat.apache.org/tomcat-8.5-doc/config/http.html
If you do not specify which characters are allowed, the Tomcat server will reject messages that contain one or more of the unencoded characters in URI paths and queries.
Add the relaxedPathChars
and relaxedQueryChars
properties to the <Connector>
element in the Tomcat's server.xml file and specify the characters you want to allow. If there is more than one <Connector>
element, add the attributes to the elements with the protocol
set to HTTP
and HTTPS
.
Example:
<Connector URIEncoding="UTF-8" allowTrace="true" connectionTimeout="20000" enableLookups="true" name="default" port="9080" protocol="HTTP/1.1" redirectPort="9443" server="Parasoft Server" relaxedPathChars="" < > [ \ ] ^ ` { | }" relaxedQueryChars="" < > [ \ ] ^ ` { | }" />
Custom Status Message Configuration
You can enable Tomcat to set a custom HTTP status code message. This allows Virtualize to customize status messages in response headers if your responders set custom HTTP status messages. Add the following property to the conf/catalina.properties file when deploying the Virtualize Server WAR file:
org.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER=true
See https://tomcat.apache.org/tomcat-8.5-doc/config/systemprops.html for additional information about setting this property.