A few thoughts on PASTA+ and Tomcat8
The PASTA+ project uses Tomcat8 as it primary servlet container and interface for interactions with its REST-based API. Here are some thoughts on how tomcat8
is deployed and being used.
1. The default Tomcat8 does not include the manager application
One way of examining memory usage by tomcat8
is to use the Tomcat8 manager application and viewing the status
page. By default, Ubuntu 18.04 does not install the manager application (at least this is true in our case). Doing so is easy:
apt install tomcat8-admin
After the manager application is installed, you will need to add the manager-gui
as a new role
to the tomcat-users.xml
file, which is found in /etc/tomcat8/tomcat-users.xml
. For example:
<role rolename="manager-gui"/>
<user username="tomcat" password="<PASSWORD>" roles="tomcat,manager-gui"/>
Once done, restart tomcat8
and you may access the manager application through the http:localhost:8080/manager/html
URL. Note that you may need to open port 8080 on your firewall to gain access to the application or use an SSH tunnel like:
ssh <SERVER> -L 7777:localhost:8080
which allows you to connect in your local browser using http:localhost:7777/manager/html
to access the remote http:localhost:8080/manager/html
website.
2. Customizing start-up specs for Java
In general, we tend to keep default settings for Ubuntu/Debian installed applications for fear of really screwing things up if we don't set things right. With tomcat8
, however, you may want to adjust the default Java
memory specifications so that it can better take advantage of your system's resources. To do this in Ubunut 18.04, you need to navigate into the /usr/share/tomcat8/bin
directory and create a file named setenv.sh
with appropriate permissions (-rwxr-xr-x
). In this, you may now set your default Java
options to your special needs. For example:
export JAVA_OPTS="-Dfile.encoding=UTF-8 -Xms256m -Xmx2048m -XX:PermSize=256m -XX:MaxPermSize=1024m"