Tomcat adds support for Java servlets and JavaServer Pages (JSP's) to the Apache web server.
cd ~/src wget http://mirror.sdunix.com/apache/tomcat/tomcat-6/v6.0.44/bin/apache-tomcat-6.0.44.tar.gz cd /usr/local tar -zxf ~/src/apache-tomcat-6.0.44.tar.gz
conf/server.xml
from the
previous version. See below for the contents of that file.
tomcat/conf/auto/mod_jk.conf
mkdir conf/auto cp ../tomcat/conf/auto/mod_jk.conf conf/auto
/usr/local/tomcat/bin/catalina.sh
to
add /home/www/java/common/gsrc_system.jar
to tomcat's CLASSPATH.
After the line:
CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jarinsert
# Added at GSRC, to serialize initialization of JSPs between the webapps: CLASSPATH="$CLASSPATH":/home/www/java/common/gsrc_system.jar
conf/jk/workers.properties
mkdir conf/jk cp ../tomcat/conf/jk/workers.properties conf/jk/Or see below for that file
Restarting the server without recompiling the java pages resulted in a 404. See jsp pages not found.
cd /usr/local tar -zxf ~/tools/apache-tomcat-4.1.40.tar.gz ln -s apache-tomcat-4.1.40 tomcat
/usr/local/tomcat/conf/server.xml
<Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" jkDebug="info"/> <!-- jkDebug can be "debug", "info", "error" or "emerg" --> <Service name="Tomcat-Standalone"> <Connector className="org.apache.ajp.tomcat4.Ajp13Connector" port="8009" minProcessors="5" maxProcessors="75" acceptCount="10"/> <Engine name="Standalone" defaultHost="localhost"> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="catalina_log." suffix=".txt" timestamp="true"/> <Realm className="org.apache.catalina.realm.MemoryRealm" /> <Host name="localhost" appBase="webapps" unpackWARs="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/> <Context path="/chessj" docBase="/home/www/java/chess" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="chessj_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/chessj" override="true"/> </Context> <Context path="/e3scenterj" docBase="/home/www/java/e3s" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="e3sjcenter_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/e3scenterj" override="true"/> </Context> <Context path="/embeddedj" docBase="/home/www/java/embedded" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="embeddedj_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/embeddedj" override="true"/> </Context> <Context path="/icyphyj" docBase="/home/www/java/icyphy" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="icyphyj_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/icyphyj" override="true"/> </Context> <Context path="/terraswarmj" docBase="/home/www/java/terraswarm" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="terraswarmj_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/terraswarmj" override="true"/> </Context> <Context path="/trustj" docBase="/home/www/java/trust" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="trustj_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/trustj" override="true"/> </Context> </Host> </Engine> </Service> </Server>
/usr/local/tomcat/conf/auto/mod_jk.conf
to be included
into apache's httpd.conf
with the "Include" directive.
/usr/local/apache/conf/tomcat-mod_jk.conf
, and
that file should be included into httpd.conf instead. The
caveat here, of course, is that you have to re-copy this file if you
ever change any mod_jk-related configuration that effects this file.
For reference, here is /usr/local/tomcat/conf/auto/mod_jk.conf
######### Auto generated on Wed Jan 27 17:28:11 PST 2016##########LoadModule jk_module "libexec/mod_jk.so" JkWorkersFile "/usr/local/tomcat/conf/jk/workers.properties" JkLogFile "/usr/local/tomcat/logs/mod_jk.log" JkLogLevel info JkMount /cps-forcesj ajp13 JkMount /cps-forcesj/* ajp13 JkMount /chessj ajp13 JkMount /chessj/* ajp13 JkMount /roboticsj ajp13 JkMount /roboticsj/* ajp13 JkMount /trustj ajp13 JkMount /trustj/* ajp13 JkMount /embeddedj ajp13 JkMount /embeddedj/* ajp13 JkMount /terraswarmj ajp13 JkMount /terraswarmj/* ajp13 JkMount /e3scenterj ajp13 JkMount /e3scenterj/* ajp13 JkMount /icyphyj ajp13 JkMount /icyphyj/* ajp13
/usr/local/tomcat/bin/catalina.sh
to
add /home/www/java/common/gsrc_system.jar
to tomcat's CLASSPATH.
After the line:
CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jarinsert
# Added at GSRC, to serialize initialization of JSPs between the webapps: CLASSPATH="$CLASSPATH":/home/www/java/common/gsrc_system.jar
/usr/local/tomcat/conf/jk/workers.properties
:
# Setup for Linux system # workers.tomcat_home=/usr/local/tomcat workers.java_home=/usr/java worker.list=ajp13 # Definition for Ajp13 worker # worker.ajp13.type=ajp13 worker.ajp13.port=8009 worker.ajp13.host=localhost
10/12: Linux
get http://mirror.sdunix.com/apache//tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.37 -src.tar.gz tar -zxf tomcat* cd tomcat-connectors-1.2.37-src cd native ./configure --with-apxs=/usr/sbin/apxs make make install< Note that
/usr/local/apache/conf/tomcat-mod_jk.conf
determines the path to
mod_jk.so
. You are better off
if you put mod_jk.so in /usr/local/apache/libexec/
. It might work elsewhere, but it
could be hard to get everything to work.
If, during startup, the mod_jk.log
file has messages about not being able to find
mod_jk.so
, then make sure
/etc/init.d/gsrc start
is run when
in the /usr/local/apache
directory.
We had a problem with blank pages, see
JSP pages not found
The next step is What is Struts and how do I install it?
Tomcat is the Reference Implementation for the Java Servlet 2.2 and JavaServer Pages 1.1 Technologies. It adds support for Java servlets and JavaServer Pages (JSP's) to the Apache web server.
cd /usr/local gtar -zxf /export/home1/root/tools/downloads/apache-tomcat-4.1.39-LE-jdk14.tar.gz
Make /usr/local/tomcat
a symbolic link to
the directory that was just created:
cd /usr/local rm tomcat ln -s apache-tomcat-4.1.39-LE-jdk14 tomcat
Edit /usr/local/tomcat/conf/server.xml
.
With patience, one could probably enable the demo webapps along with
the GSRC webapp, but I didn't get much sucess until I trimmed
server.xml down to bare essentials. As of 12/12/02 (after adding
the Chess application) that means this:
<Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" jkDebug="info"/> <!-- jkDebug can be "debug", "info", "error" or "emerg" --> <Service name="Tomcat-Standalone"> <Connector className="org.apache.ajp.tomcat4.Ajp13Connector" port="8009" minProcessors="5" maxProcessors="75" acceptCount="10"/> <Engine name="Standalone" defaultHost="localhost"> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="catalina_log." suffix=".txt" timestamp="true"/> <Realm className="org.apache.catalina.realm.MemoryRealm" /> <Host name="localhost" appBase="webapps" unpackWARs="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/> <Context path="/gsrcj" docBase="/home/www/java/gigascale" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <!-- jkDebug can be "debug", "info", "error" or "emerg" --> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="gsrcj_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/gsrcj" override="true"/> </Context> <Context path="/chessj" docBase="/home/www/java/chess" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="chessj_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/chessj" override="true"/> </Context> <Context path="/embeddedj" docBase="/home/www/java/embedded" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="embeddedj_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/embeddedj" override="true"/> </Context> <Context path="/trustj" docBase="/home/www/java/trust" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="trustj_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/trustj" override="true"/> </Context> </Host> </Engine> </Service> </Server>If you are on carson, then
<Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" jkDebug="info"/> <!-- jkDebug can be "debug", "info", "error" or "emerg" --> <Service name="Tomcat-Standalone"> <Connector className="org.apache.ajp.tomcat4.Ajp13Connector" port="8009" minProcessors="5" maxProcessors="75" acceptCount="10"/> <Engine name="Standalone" defaultHost="localhost"> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="catalina_log." suffix=".txt" timestamp="true"/> <Realm className="org.apache.catalina.realm.MemoryRealm" /> <Host name="localhost" appBase="webapps" unpackWARs="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/> <Context path="/andrewsj" docBase="/home/www/java/andrews" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <!-- jkDebug can be "debug", "info", "error" or "emerg" --> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="andrewsj_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/andrewsj" override="true"/> </Context> <Context path="/chessj" docBase="/home/www/java/chess" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="chessj_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/chessj" override="true"/> </Context> <Context path="/embeddedj" docBase="/home/www/java/embedded" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="embeddedj_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/embeddedj" override="true"/> </Context> <Context path="/trustj" docBase="/home/www/java/trust" reloadable="true" crossContext="true"> <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" forwardAll="true" noRoot="true" jkDebug="info" append="true"/> <Logger className="org.apache.catalina.logger.FileLogger" verbosity="4" prefix="trustj_log." suffix=".txt" timestamp="true"/> <Parameter name="appURLBase" value="/trustj" override="true"/> </Context> </Host> </Engine> </Service> </Server>
When Tomcat starts up, with this configuration, and with mod_jk
installed (see below), it generates a file called
/usr/local/tomcat/conf/auto/mod_jk.conf
to be included
into apache's httpd.conf
with the "Include" directive.
To avoid a race condition on startup, this file should be copied by
hand to /usr/local/apache/conf/tomcat-mod_jk.conf
, and
that file should be included into httpd.conf instead. The
caveat here, of course, is that you have to re-copy this file if you
ever change any mod_jk-related configuration that effects this file.
Edit /usr/local/tomcat/bin/catalina.sh
to
add /home/www/java/common/gsrc_system.jar
to tomcat's CLASSPATH.
After the line:
CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jarinsert
# Added at GSRC, to serialize initialization of JSPs between the webapps: CLASSPATH="$CLASSPATH":/home/www/java/common/gsrc_system.jar
Create /usr/local/tomcat/conf/jk/workers.properties
:
# Setup for Solaris system # workers.tomcat_home=/usr/local/tomcat workers.java_home=/usr/java worker.list=ajp13 # Definition for Ajp13 worker # worker.ajp13.type=ajp13 worker.ajp13.port=8009 worker.ajp13.host=localhost
Problem: example-taglib.tld
java.lang.IllegalArgumentException: Invalid TLD resource path /WEB-INF/jsp/example-taglib.tldRemoved the following from
/home/www/java/trust/WEB-INF/web.xml
<taglib> <taglib-uri> http://java.apache.org/tomcat/examples-taglib </taglib-uri> <taglib-location> /WEB-INF/jsp/example-taglib.tld </taglib-location> </taglib>
Problem:
javax.servlet.ServletException: Parsing error processing resource path /WEB-INF/struts-config.xml
/usr/local
.
cd /usr/local ln -s junit3.7 junit.(To use JUnit, just add /usr/local/junit/junit.jar to CLASSPATH.)
http://ant.apache.org/
and untar it in /usr/local
. Then:
cd /usr/local ln -s apache-ant-1.7.1 ant cd bin ln -s ../ant/bin/ant . ln -s ../ant/bin/antRun .There's also a runant.pl and runant.py in the bin directory, which I'm ignoring.
Old jakarta installation instructions
(6/05:
http://archive.apache.org/dist/jakarta/tomcat-4/archive/v4.0.4/src/jakarta-tomcat-connectors-4.0.4-src.tar.gz
) unzip it into/home/tools
. cd into its "jk" directory.The README file here says to copy & edit build.properties and run "ant install". This didn't install mod_jk.so as expected for me.
I had to go down into subdirectory jk/native/apache-2.0, read the README.solaris file there & do what it says:
Ignore the rest of the instructions in this directory about apache configuration. They pertain to Tomcat version 3. Refer instead to
- edit build-unix.sh, setting JAVA_HOME and APACHE_HOME to the right pathnames, and run build-solaris.sh, as root.
- also add the "-DEAPI" flag to the apxs command that does the compiling in build-solaris.sh (in response to errors I got below)
- As root,
$ sh build-solaris.shI had to copy mod_jk.so by hand:cp .libs/mod_jk.so /usr/local/apache/modules/http://tomcat.apache.org/tomcat-4.0-doc/config/ajp.html
for information about configuring apache.
Create a new /etc/init.d/tomcat script that invokes /usr/local/tomcat/bin/startup.sh and shutdown.sh. This includes first setting $JAVA_HOME to /usr/java. It also includes setting two environment variables before invoking /usr/local/tomcat/bin/startup.sh: JAVA_OPTS is set to "-Xms128m -XMx128m" to double the heap size of Tomcat's JVM, and LD_LIBRARY_PATH to "/home/www/gsrcwww/java/WEB-INF/lib" to find the JNI libraries. As of 6/05, /etc/init.d/tomcat looks like this, but it is bound to have undergone changes since this time. :
#!/bin/bash # # Start/stop/retart Tomcat version 4. # PROG=${0##*/} TOMCAT_BIN=/usr/local/tomcat/bin export JAVA_HOME=/usr/java USAGE_STRING="usage: ${PROG} start | stop | restart" PATIENCE=10# seconds # All this "webapp" stuff, and the LD_LIBRARY_PATH stuff is obsolete & can # be deleted, now that users' passwords are stored in MySQL. ajh 3/24/03 # WEBAPP_HOME=/home/www/java # # $WEBAPPS is the names of the directories in $WEBAPP_HOME that are the # # roots of the website servlet applications (or "webapps"); # # These match the values of the "docBase" parameters of the "Context" tags # # in /usr/local/tomcat/server.xml. # WEBAPPS="gigascale chess citris" # Add others as needed, like this. usage() { echo "${USAGE_STRING}" 1>&2 } get_tomcat_pid() { grepString='org.apache.catalina.startup.Bootstrap start$' /usr/ucb/ps -auxww | egrep "${grepString}" | egrep -v egrep | awk '{print $2}' } if [ $# -ne 1 ]; then usage exit 1 fi case "$1" in # Try increasing java's heap size (from default 64MB to 128) # for pesky "blah may not have been initialized" problem w/ JSPs start) # for app in $WEBAPPS; do # appPath=${WEBAPP_HOME}/${app}/WEB-INF/lib # javaLibraryPath=${javaLibraryPath}${javaLibraryPath:+":"}$appPath # done # LD_LIBRARY_PATH=${JAVA_LIBRARY_PATH}${JAVA_LIBRARY_PATH:+":"}${javaLibraryPath} JAVA_OPTS="-Xms128m -Xmx128m" ${TOMCAT_BIN}/startup.sh pid=`get_tomcat_pid` while [ ! "${pid}" -a ${PATIENCE} -gt 0 ]; do sleep 1 PATIENCE=$(( $PATIENCE - 1 )) pid=`get_tomcat_pid` done if [ ${PATIENCE} -eq 0 ]; then echo "${PROG}: tomcat would not start." 1>&2 exit 2 fi ;; stop)pid=`get_tomcat_pid` if [ "${pid}" ]; then ${TOMCAT_BIN}/shutdown.sh && { pid=`get_tomcat_pid` while [ "${pid}" -a ${PATIENCE} -gt 0 ]; do sleep 1 PATIENCE=$(( $PATIENCE - 1 )) pid=`get_tomcat_pid` done if [ "${pid}" -a ${PATIENCE} -eq 0 ]; then echo "${PROG}: tomcat would not die." 1>&2 echo " (PID = ${pid})" 1>&2 exit 2 fi } fi ;; restart)if $0 stop ; then $0 start else status=$? echo "Tomcat NOT RESTARTED!" 1>&2 exit $status fi # For a few seconds after starting up, this process # does exist, but is not ready to accept a shutdown. # In that case, the "stop" command will fail, and # spit out a ConnectException stack trace. ;; *)usage; exit 1 ;; esac
There is now a conflict stemming from the web app being based at URL "/gsrc". Pages that used to be dealt with by PHP as pointing to the "gsrc" workgroup now never get handed off to PHP by Apache at all. For this reason I've changed tomcat's root URL from "gsrc" to "gsrcj". This has required a handful of code changes in both PHP and JSP/servlet code. This string, "/gsrcj" is now a servlet configuration parameter in /usr/local/tomcat/conf/server.xml.