Prerequisites
- Java 11 or later. Oracle and OpenJDK versions are supported.
JAVA_HOME must point to the JRE/JDK. You can run
echo $JAVA_HOME
(Linux) orecho %JAVA_HOME%
(Windows) to verify this.PATH must include the path to java executable. You can run
java
to verify that the executable is found.CTP downloaded (via download link). You can request a download link by sending an email to your Parasoft representative.
Linux (Red Hat)
- Download Apache Tomcat 9.0 from http://tomcat.apache.org/.
- Log in to the system as
root
. - Extract Tomcat.
tar –zxvf apache-tomcat-<version>
This will create a new folder containing Tomcat. - (Recommended) Move the extracted folder to a common installation location, such as
/opt/tomcat
.
You may also want to configure Tomcat to start automatically when the server starts. There are two ways to do this:
- Edit init.d and using that to start/stop Tomcat, or
- Directly call startup.sh located in the
<apache-tomcat-home>/bin/
directory.
Editing init.d
cd /etc/init.d/
vi tomcat
Edit the file to look like this:
#!/bin/bash # description: Tomcat Start Stop Restart # processname: tomcat # chkconfig: 234 20 80 JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 export JAVA_HOME PATH=$JAVA_HOME/bin:$PATH export PATH CATALINA_OPTS="-Xmx768m -XX:MaxPermSize=256m" export CATALINA_OPTS CATALINA_HOME=/usr/share/apache-tomcat-9.0.83 TOMCAT_OWNER=parasoft case $1 in start) su - $TOMCAT_OWNER -c $CATALINA_HOME/bin/startup.sh ;; stop) su - $TOMCAT_OWNER -c $CATALINA_HOME/bin/shutdown.sh ;; restart) su - $TOMCAT_OWNER -c $CATALINA_HOME/bin/shutdown.sh su - $TOMCAT_OWNER -c $CATALINA_HOME/bin/startup.sh ;; esac exit 0
where TOMCAT_OWNER=parasoft
references a user named ‘parasoft
’ to run the Tomcat service.
To start the Tomcat service:
/etc/init.d/tomcat start
To stop the Tomcat service:
/etc/init.d/tomcat stop
To restart the Tomcat service:
/etc/init.d/tomcat restart
To ensure that Tomcat gets started automatically at boot:
chkconfig tomcat on
Directly Calling startup.sh
Alternatively, you can start Tomcat by directly calling the startup.sh script located in the <apache-tomcat-home>/bin/
directory. If starting Tomcat this way, you will need to create a setenv.sh script in the <apache-tomcat-home>/bin/
directory with the following contents:
CATALINA_OPTS="-Xmx768m -XX:MaxMetaspaceSize=256m"
Windows
- Download the Apache Tomcat 9.0 32-bit/64-bit Windows Service Installer from
http://tomcat.apache.org/ - Run the installer. Choose Service Startup during installation.
- After installation, open the Tomcat configuration controls from the system tray.
- For Java Options, set the maximum size of the Metaspace using
-XX:MaxMetaspaceSize=256m
(Java Options are separated by new lines, not spaces) and set the maximum heap size to 768 MB.
Configuring SSL/HTTPS on Tomcat
CTP receives user passwords over a web interface. To ensure that passwords are encrypted when they are sent over the network, Tomcat should be configured to use only the HTTPS connector. For instructions on how to configure HTTPS in Tomcat, see the Apache Tomcat SSL/TLS Configuration HOW-TO topic.
Configuring Tomcat to Log User Information with CTP Requests and Responses
CTP is distributed with the tools you need to configure Tomcat to log user information along with each request and response. This is necessary for some users to be in compliance with certain regulations.
To configure Tomcat to log this information from CTP, you need to:
- Add ctp_access_log.jar (distributed with CTP) to the
<apache-tomcat-home>/lib
directory. Edit the server.xml file located in the
<apache-tomcat-home>
/conf/
directory by finding the default access log valve entry:<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
And appending the following example as a new entry:
<Valve className="com.parasoft.ctp.access.log.CTPAccessLogValve" prefix="ctp" suffix=".txt" pattern="%t %s %m %U %H %u %S %A:%{local}p %a:%{remote}p %F %{X-Forwarded-For}i %{User-Agent}i %{Referer}i %I" />
Standard Tomcat access log parameters are supported. See https://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Access_Logging for more information.
Additional Configuration for UTF-8 Encoding
To ensure proper parsing of Japanese characters and other non-ASCII characters, add URIEncoding="UTF-8"
to the <Connector>
in Tomcat's server.xml file. For example:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />