Users of GCJ and OS-provided packages (linux) for Java and/or Tomcat may want to reference the THREDDS mailing list for installation help.
Note: TDS version 4.3 will require the use of Tomcat 7.
While there are different distributors of Java and servlet containers, Unidata develops, uses and tests the THREDDS Data Server using Sun Java and the Apache Tomcat servlet container.
At the time of this workshop, that is version 1.6.0_26. We will be using the Linux x64-bit, non-rpm, self-extracting file:
jdk-6u26-linux-x64.bin
Copy the self-extracting file to the installation directory (~/GettingStarted is the installation directory in this example):
$ pwd /home/tds $ cp Downloads/jdk-6u26-linux-x64.bin GettingStarted/ $ cd GettingStarted
Change the permissions on the file to be executable:
$ ls -l -rw-r--r-- 1 tds Unidata 85407904 Jul 11 17:26 jdk-6u26-linux-x64.bin $ chmod 775 jdk-6u26-linux-x64.bin $ ls -l -rwxrwxr-x 1 tds Unidata 85407904 Jul 11 17:26 jdk-6u26-linux-x64.bin
Run self-extracting file and agree to the terms of the code license:
$ ./jdk-6u26-linux-x64.bin
This will extract the JDK in the ~/GettingStarted directory:
$ ls -l drwxr-xr-x 10 tds Unidata 4096 Jul 11 17:35 jdk1.6.0_26 -rwxrwxr-x 1 tds Unidata 85407904 Jul 11 17:26 jdk-6u26-linux-x64.bin
At the time of this workshop, that is version 6.0.32. We will be using the core binary tar.gz file:
apache-tomcat-6.0.32.tar.gz
Copy the binary tar.gz file to the installation directory (~/GettingStarted is the installation directory in this example):
$ pwd /home/tds/GettingStarted $ cp ~/Downloads/apache-tomcat-6.0.32.tar.gz .
Unpack the archive to create Tomcat directory:
$ tar xvzf apache-tomcat-6.0.32.tar.gz $ ls -ld apache-tomcat-6.0.32 drwxr-xr-x 9 tds Unidata 4096 Jul 11 17:47 apache-tomcat-6.0.32
/home/tds/GettingStarted$CATALINA_HOME (also can be called $TOMCAT_HOME). Move into $CATALINA_HOME and do a long listing:
$ cd apache-tomcat-6.0.32 $ ls -l total 92 drwxr-xr-x 2 tds Unidata 4096 Jul 11 17:47 bin drwxr-xr-x 2 tds Unidata 4096 Feb 2 12:06 conf drwxr-xr-x 2 tds Unidata 4096 Jul 11 17:47 lib -rw-r--r-- 1 tds Unidata 37951 Feb 2 12:06 LICENSE drwxr-xr-x 2 tds Unidata 4096 Feb 2 12:04 logs -rw-r--r-- 1 tds Unidata 558 Feb 2 12:06 NOTICE -rw-r--r-- 1 tds Unidata 8672 Feb 2 12:04 RELEASE-NOTES -rw-r--r-- 1 tds Unidata 6670 Feb 2 12:06 RUNNING.txt drwxr-xr-x 2 tds Unidata 4096 Jul 11 17:47 temp drwxr-xr-x 7 tds Unidata 4096 Feb 2 12:04 webapps drwxr-xr-x 2 tds Unidata 4096 Feb 2 12:04 work
bin/
startup.sh, shutdown.sh and other scripts/programs.*.sh files (for Unix systems) are functional duplicates of the *.bat files (for Windows systems).conf/
server.xml and tomcat-users.xml to adjust logging, authentication and access control, enable SSL, etc.webapps/
manager application that comes with Tomcat during this workshop.logs/
catalina.out and localhost_access_log.yyyy-mm-dd.log files by the end of this workshop.Run the startup.sh script in the Tomcat bin/ directory:
$ pwd /home/tds/GettingStarted/apache-tomcat-6.0.32 $ bin/startup.sh
Look and see if you have a Tomcat process running:
$ ps -ef | grep tomcat tds 27049 1 2 17:50 pts/1 00:00:02 /usr/bin/java -Djava.util.logging.config.file=/home/tds/GettingStarted/apache-tomcat-6.0.32/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/home/tds/GettingStarted/apache-tomcat-6.0.32/endorsed -classpath /home/tds/GettingStarted/apache-tomcat-6.0.32/bin/bootstrap.jar -Dcatalina.base=/home/tds/GettingStarted/apache-tomcat-6.0.32 -Dcatalina.home=/home/tds/GettingStarted/apache-tomcat-6.0.32 -Djava.io.tmpdir=/home/tds/GettingStarted/apache-tomcat-6.0.32/temp org.apache.catalina.startup.Bootstrap start
Open a new browser window/tab and go to http://localhost:8080/ to verify Tomcat is running:
Which Java is Tomcat currently using? (Hint: what was sent to STDOUT when running the startup.sh and shutdown.sh?)
Run the shutdown.sh script in the Tomcat bin/ directory:
$ bin/shutdown.sh
Which Java is Tomcat currently using? (Hint: what was sent to STDOUT when running the startup.sh and shutdown.sh?)
logs for clues about why Tomcat failed to start or stop.catalina.out.$JAVA_HOME, $JAVA_OPTS and $CATALINA_HOMEWe are going to create a file called setenv.sh in the Tomcat bin/ directory to:
$JAVA_HOME and $CATALINA_HOME) during startup and shutdown; and $JAVA_OPTS.
Why are we setting $JAVA_HOME and $CATALINA_HOME if we already have set them in our environment?
setenv.sh file.Using your favorite text editor (gedit, vi, emacs, etc.), create a new file called setenv.sh in the Tomcat bin/ directory:
$ pwd /home/tds/GettingStarted/apache-tomcat-6.0.32 $ cd bin $ vi setenv.sh
Add the following information and save your setenv.sh file:
#!/bin/sh # # ENVARS for Tomcat and TDS environment # JAVA_HOME="/home/tds/GettingStarted/jdk1.6.0_26" export JAVA_HOME JAVA_OPTS="-Xmx4096m -Xms512m -server -Djava.awt.headless=true -Djava.util.prefs.systemRoot=$CATALINA_HOME/content/thredds/javaUtilPrefs" export JAVA_OPTS CATALINA_HOME="/home/tds/GettingStarted/apache-tomcat-6.0.32" export CATALINA_HOME
Whenever possible, Unidata recommends -Xmx1500m for 32-bit systems, and-Xmx4096m (or more) for 64-bit systems.
The parameters we pass to $JAVA_OPTS:
-Xms is the initial allocated memory of the JVM (for performance).-Xmx the maximum allocated memory of the JVM (for performance).-server tells the Hostspot compiler to run the JVM in "server" mode.-Djava.awt.headless=true is needed to prevent graphics rendering code from assuming a graphics console exists. Without this, WMS code will crash the server in some circumstances.-Djava.util.prefs.systemRoot=$CATALINA_HOME/content/thredds/javaUtilPrefs allows the java.util.prefs of the TDS WMS service to write system preferences to a location that is writable by the user that Tomcat runs underRestart Tomcat and examine the output generated to the terminal window by the startup script:
$ ./startup.sh Using CATALINA_BASE: /home/tds/GettingStarted/apache-tomcat-6.0.32 Using CATALINA_HOME: /home/tds/GettingStarted/apache-tomcat-6.0.32 Using CATALINA_TMPDIR: /home/tds/GettingStarted/apache-tomcat-6.0.32/temp Using JRE_HOME: /home/tds/GettingStarted/jdk1.6.0_26 Using CLASSPATH: /home/tds/GettingStarted/apache-tomcat-6.0.32/bin/bootstrap.jar
Did you notice any difference in the what is being reported to STDOUT during startup?
Take a look at the running Tomcat process to see the new $JAVA_OPTS settings:
$ ps -ef | grep tomcat tds 2697 1 7 17:59 pts/1 00:00:03 /home/tds/GettingStarted/jdk1.6.0_26/bin/java -Djava.util.logging.config.file=/home/tds/GettingStarted/apache-tomcat-6.0.32/conf/logging.properties -Xmx1500m -Xms512m -server -Djava.awt.headless=true -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/home/tds/GettingStarted/apache-tomcat-6.0.32/endorsed -classpath /home/tds/GettingStarted/apache-tomcat-6.0.32/bin/bootstrap.jar -Dcatalina.base=/home/tds/GettingStarted/apache-tomcat-6.0.32 -Dcatalina.home=/home/tds/GettingStarted/apache-tomcat-6.0.32 -Djava.io.tmpdir=/home/tds/GettingStarted/apache-tomcat-6.0.32/temp org.apache.catalina.startup.Bootstrap start
What allows us to create the setenv.sh file and have its contents read? (Hint: have a look at the catalina.sh file in the Tomcat bin/ directory starting around line 117).
m' in your -Xms and -Xmx settings.catalina.out:Error occurred during initialization of VM Could not reserve enough space for object heap
setenv.sh file, it will be reported to catalina.out:Error occurred during initialization of VM Incompatible minimum and maximum heap sizes specified
$JAVA_HOME, $JAVA_OPTS and $CATALINA_HOMEsetenv.sh file in the Tomcat bin/ and set $JAVA_HOME, $JAVA_OPTS and $CATALINA_HOME.thredds.warWe will be using the current TDS 4.2 (stable) version for this workshop:
thredds.war
Put thredds.war in the Tomcat webapps/ directory:
$ pwd /home/tds/GettingStarted/apache-tomcat-6.0.32/bin $ cd ../webapps $ cp ~/Downloads/thredds.war . $ ls -l total 24612 drwxr-xr-x 10 tds Unidata 4096 Jul 11 17:47 docs drwxr-xr-x 5 tds Unidata 4096 Jul 11 17:47 examples drwxr-xr-x 5 tds Unidata 4096 Jul 11 17:47 host-manager drwxr-xr-x 5 tds Unidata 4096 Jul 11 17:47 manager drwxr-xr-x 3 tds Unidata 4096 Jul 11 17:47 ROOT -rw-r--r-- 1 tds Unidata 25238961 Jul 11 18:02 thredds.war
If Tomcat is already running, wait a couple of seconds after placing the WAR file in the Tomcat webapps/ and then verify the thredds.war file was unpacked:
$ ls -l total 24616 drwxr-xr-x 10 tds Unidata 4096 Jul 11 17:47 docs drwxr-xr-x 5 tds Unidata 4096 Jul 11 17:47 examples drwxr-xr-x 5 tds Unidata 4096 Jul 11 17:47 host-manager drwxr-xr-x 5 tds Unidata 4096 Jul 11 17:47 manager drwxr-xr-x 3 tds Unidata 4096 Jul 11 17:47 ROOT drwxr-xr-x 6 tds Unidata 4096 Jul 11 18:02 thredds -rw-r--r-- 1 tds Unidata 25238961 Jul 11 18:02 thredds.war
Go to http://localhost:8080/thredds/ in your browser to verify the TDS has been deployed:
catalina.out file of the Tomcat logs/ directory. ~/GettingStarted/apache-tomcat-6.0.32 (aka $TOMCAT_HOME).Do you notice anything new?
logs/logs/ directory.Move into the logs/ directory to see the type of information being logged:
$ pwd /home/tds/GettingStarted/apache-tomcat-6.0.32/webapps $ cd ../logs $ ls -l total 20 -rw-r--r-- 1 tds Unidata 4423 Jul 11 18:02 catalina.2011-07-11.log -rw-r--r-- 1 tds Unidata 4741 Jul 11 18:02 catalina.out -rw-r--r-- 1 tds Unidata 0 Jul 11 17:50 host-manager.2011-07-11.log -rw-r--r-- 1 tds Unidata 2132 Jul 11 18:02 localhost.2011-07-11.log -rw-r--r-- 1 tds Unidata 0 Jul 11 17:50 manager.2011-07-11.log
Do you see a correspondence between some of the web applications in the Tomcat webapps/ directory and the naming of certain log files?
Is there a difference in the information being logged to catalina.out versus catalina.yyyy-mm-dd.log?
Are some log files more verbose than others?
catalina.out.Open another terminal window (hereafter referred to as terminal #2) and run the following command in the new terminal:
$ tail -f /home/tds/GettingStarted/apache-tomcat-6.0.32/logs/catalina.out
In your original terminal window, start/stop and start Tomcat and watch what is being logged to catalina.out in the terminal #2 window.
Is it only errors messages being reported to catalina.out?
What messages in catalina.out are from the TDS?
catalina.outcatalina.outThe Tomcat Users mailing list has seen a lot of traffic dedicated to catalina.out logging and rotation.
System.out and System.err gets appended to catalina.out. catalina.out can quickly grow large if the hosted web applications are not specifically catching and logging System.out and System.err to designated files.catalina.out is not automatically rotated in Tomcat.logadm or logrotate) to rotate catalina.out.catalina.out files and other log files out of the Tomcat logs/ on a regular basis.server.xml Tomcat's configuration files, including server.xml can be found in in the Tomcat conf/ directory.
server.xml do not take effect until Tomcat is restarted.server.xmlserver.xml.Move into the Tomcat conf/ directory and examine the server.xml file:
$ pwd /home/tds/GettingStarted/apache-tomcat-6.0.32/logs $ cd ../conf $ less server.xml
Reference the table below to see how the server.xml elements relate to configuring TDS (mouse-over the element for a description):
tomcat-users.xml tomcat-users.xml do not take effect until Tomcat is restarted.tomcat-users.xmltomcat-users.xml.Open the tomcat-users.xml file:
$ pwd /home/tds/GettingStarted/apache-tomcat-6.0.32/conf $ less tomcat-users.xml
Reference the table below to see how the tomcat-users.xml elements relate to configuring TDS (mouse-over the element for a description):
| Tag Name | Instances | How it relates to the TDS |
|---|---|---|
<tomcat-users>Description: The tomcat-users element represents the single outermost element in tomcat-users.xml
|
1...1 | Not modified. (The only tag you get by default.) |
<role>Description: The role element defines one role or group a user can belong to.
|
1...* |
You will have at least two of these: one for the Tomcat manager application and one for the TDS. (You will need to add if you want to enable role-based authentication.)
|
<user>Description: The user element represents one valid user.
|
1...* |
You will need to create an entry for each user who needs access to the Tomcat manager application and/or the restricted areas of the TDS. (You will need to add if you want to enable user authentication.)
|
manager Applicationmanager applicationmanagerFor more information about the Tomcat manager application, see the Tomcat Manager App HOW-TO documentation.
manager directory in the Tomcat webapps/ directory. server.xml.manager applicationmanager applicationThe manager application URLs and roles has been re-structured. See the Tomcat Migration guide for more information.
Attempt to access the Tomcat manager application in your browser: http://localhost:8080/manager/html/. You will be prompted to login via BASIC authentication, which will end in failure since we do not yet have permission to access the manager application:
Based on what we know about Tomcat configuration, which file in the Tomcat conf/ directory should we edit to grant ourselves access to the manager application?
manager applicationtomcat-users.xml to add role and user elements.Using your favorite editor, open $TOMCAT_HOME/conf/tomcat-users.xml:
$ vi tomcat-users.xml
Between the <tomcat-users> tags, add a role element and specify the rolename attribute as manager:
<tomcat-users>
<role rolename="manager-gui"/>
</tomcat-users>
Now add a new user by adding a user element. Create a username and password for the new user and specify manager-gui as one of the roles (in this example we are creating a user called 'admin' with a corresponding password of 'secret'):
<tomcat-users>
<role rolename="manager-gui"/>
<user username="admin" password="secret" roles="manager-gui"/>
</tomcat-users>
manager application.Changes to tomcat-users.xml do not take effect until Tomcat is restarted.
Attempt to access the manager application again (http://localhost:8080/manager/html/), this time logging in using the name and password specified in tomcat-users.xml:
To gain access to restricted parts of the TDS, you will perform the same steps you used to grant yourself access to the manager application.
Voilà! You should have access to the manager application.
tomcat-users.xml to make sure it is well-formed and without error.tomcat-users.xml?logs/catalina.out file. manager applicationtomcat-users.xml to grant yourself access to the Tomcat manager application.manager applicationmanager application to undeploy the TDS.Find the TDS in the list of web application on the Applications page. Stop and then Undeploy the TDS:

List the contents of the Tomcat webapps/ directory to verify that both thredds.war and the unpacked thredds/ directory have been removed:
$ pwd /home/tds/GettingStarted/apache-tomcat-6.0.32/conf $ cd ../webapps $ ls -l total 20 drwxr-xr-x 10 tds Unidata 4096 Jul 11 17:47 docs drwxr-xr-x 5 tds Unidata 4096 Jul 11 17:47 examples drwxr-xr-x 5 tds Unidata 4096 Jul 11 17:47 host-manager drwxr-xr-x 5 tds Unidata 4096 Jul 11 17:47 manager drwxr-xr-x 3 tds Unidata 4096 Jul 11 17:47 ROOT
manager application.Upload the TDS WAR file using the Deploy section of the manager application:
Confirm the deployment went as planned by accessing the TDS using your browser: http://localhost:8080/thredds/
manager applicationmanager application.manager applicationPermGen infoFor a really good description of the issue, see this series of three articles:
The dreaded java.lang.OutOfMemoryError: PermGen space failure error:
manager application, your WAR file is unpacked and parts of the class file definition are loaded into PermGen space, like string constants.manager application that never completes a task, and the java.lang.OutOfMemoryError: PermGen space failure error being displayed in $TOMCAT_HOME/logs/catalina.out -XX:MaxPermSize switch to $JAVA_OPTS to increase the amount of memory allocated for the permanent generation, However this is only postponed the inevitable, as even an increased memory in permanent generation will eventually fill up. When this happens, you will need to stop/start Tomcat at this point. For this reason, you may want to restart Tomcat whenever you redeploy TDS or another webapp.You will need to enable Enable SSL encryption to access TDS remote management tool.
This document is maintained by Unidata. Send comments to THREDDS support.