eXTReMe Tracker

Macromedia Flex on Tomcat-HOWTO

Prev Next Home


3. Tomcat Installation

3.1 What is Tomcat

From the Apache Tomcat web page (http://jakarta.apache.org/tomcat/index.html):

Apache Tomcat is the servlet container that is used in the official Reference Implementation for the Java Servlet and JavaServer Pages technologies. The Java Servlet and JavaServer Pages specifications are developed by Sun under the Java Community Process.

A Java servlet container is required to run Macromedia Flex and Tomcat is available freely under the Apache Software License. While the latest version of Tomcat, version 5.5.9, is not a supported application server for Macromedia Flex, while Tomcat 4.1.29 and 5.0.18 are, I have experienced no problems whatsoever using 5.5.9, and the performance increase is noticeable.

3.2 Installing Tomcat

Download the latest version of the Tomcat binary and admin packages from the Tomcat 5.x download page:

http://tomcat.apache.org/download-55.cgi

Extract the binary and admin packages.

tar -xvzf jakarta-tomcat-5.5.9.tar.gz
tar -xvzf jakarta-tomcat-5.5.9-admin.tar.gz

Move the jakarta-tomcat-5.5.9 directory to /usr/java/tomcat

mv jakarta-tomcat-5.5.9 /usr/java/tomcat

Start the Tomcat servlet container:

/usr/java/tomcat/bin/startup.sh

Tomcat runs by default on port 8080, so test the Tomcat servlet container by browsing to http://localhost:8080/

3.3 Autostart Tomcat

If you want Tomcat to start automatically on server start, you can copy the catalina.sh script to your /etc/init.d directory, and with a few modifications incorporate the script into chkconfig.

mv /usr/java/tomcat/bin/catalina.sh /etc/init.d/catalina

Edit /etc/init.d/catalina then immediately following the first comments add:

# chkconfig: - 90 15
# description: Jakarta Tomcat Java Servlets and JSP server
CATALINA_HOME=/usr/java/tomcat
JAVA_HOME=/usr/java/jdkxxx
status() {
   ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}' | wc | awk '{print $2}' > /tmp/tomcat_process_count.txt
   read line < /tmp/tomcat_process_count.txt
   if [ $line -gt 0 ] ; then
      echo -n "Tomcat ( pid "
      ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}'
      echo -n ") is running..."
      echo
   else
      echo "Tomcat is stopped."
   fi
}

After the line # ---- Execute the Requested Command ---- enclose the block of echo commands within an if condition:

# ---- Execute the Requested Command ----
if [ "$1" != "status"]; then
   echo "Using CATALINA_BASE:   $CATALINA_BASE"
   echo "Using CATALINA_HOME:   $CATALINA_HOME"
   echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
   if [ "$1" = "debug" -o "$1" = "javac" ] ; then
     echo "Using JAVA_HOME:       $JAVA_HOME"
   else
     echo "Using JRE_HOME:       $JRE_HOME"
   fi
fi

Before the second to last else statement add:

elif [ "$1" = "status" ];then
   status
elif [ "$1" = "restart" ];then
   $0 stop
   $0 start

To add /etc/init.d/catalina to chkconfig use the following commands:

chkconfig --add catalina
chkconfig catalina on

Next
Installing Macromedia Flex
Prev
Installing Java Development Kit

Home