How to upgrade Tomcat?
Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

How to upgrade Tomcat?

In this document, $TOMCAT_HOME is used to refer to the absolute path of the directory containing the working Tomcat server, and $WORK_DIR is used to refer to the directory you prefer to work in.

Steps to upgrade Tomcat

1. Unzip the new downloaded Tomcat9.zip archive into the $WORK_DIR

$ cp Tomcat9x.zip $WORK_DIR

$ cd WORK_DIR

$ unzip Tomcat9x.zip

2. Change directory to new Tomcat conf.

$ cd tomcat-as/conf

3. Edit the new context.xml file and configure the database connection pool by referring to the working context.xml and save the file.

$ vi context.xml

4. Edit the new server.xml file and configure the Tomcat ports by referring to the working server.xml file and save the file.

$ vi server.xml

5. Copy the openspecimen.properties from working tomcat-as/conf/ directory to new tomcat-as/conf directory.

$ cp $TOMCAT_HOME/tomcat-as/conf/openspecimen.properties $WORK_DIR/tomcat-as/conf/.

6. Copy the openspecimen.war file from working tomcat-as/webapps/ directory to new tomcat-as/conf directory.

$ cp $TOMCAT_HOME/tomcat-as/webapps/openspecimen.war $WORK_DIR/tomcat-as/webapps/

7. Rename the working Tomcat directory to old_tomcat-as and compress that directory.

$ cd $TOMCAT_HOME

$ mv tomcat-as old_tomcat-as

$ zip -r old_tomcat-as.zip old_tomcat-as

8. Copy the new tomcat-as directory from OpenSpecimen build to the current Tomcat directory path.

$ cp -r $WORK_DIR/tomcat-as $TOMCAT_HOME

8. configure the Tomcat to run as a service.

Please refer to this Wiki page.

Additional Configuration (Tomcat 9.0.91 onwards)

For Ubuntu/Linux:

  1. Open the catalina.sh file located at /usr/local/tomcat-as/bin/catalina.sh.

  2. Search for the comment line:
    # Add the JAVA 9 specific start-up parameters required by Tomcat

  3. Add the following line below that comment:
    JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.net=ALL-UNNAMED"

  4. Add the attribute notFoundClassResourceCacheSize="0" to the <Context> tag at the top of the file.
    Example:
    <Context notFoundClassResourceCacheSize="0">

For Windows:

  1. Open the context.xml file in the new Tomcat's conf folder.

  2. Add the attribute notFoundClassResourceCacheSize="0" to the <Context> tag at the top of the file.
    Example:
    <Context notFoundClassResourceCacheSize="0">

  3. Open the service.bat file in the bin folder using Notepad++ or another text editor.

  4. Find the --JvmOptions9 section and add:
    --add-opens=java.base/java.net=ALL-UNNAMED#

Note:

  1. Before following the above steps, please make sure Tomcat is not in a running state.

 

Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com