Two or more instances of Tomcat 6 with 1 global lib and instance-based libs?

The server I’ll be deploying my web apps to is a Red Hat box with 2 instances of a single Tomcat 6 installation on it. These instances provide our team with the capabilities they need to move along the migration sequence, but the problem is that each instance directory (i.e. - “test1” and “test2”) lack working lib directories with which to load jar files from. We need this.

Is this managed through the use of that CATALINA.PROPERTIES file?

Here’s the basic structure as it stands:

PRIMARY / GLOBAL OUT-OF-THE-BOX TOMCAT FILES -
/usr/tomcat
/usr/tomcat/conf+lib
/usr/tomcat/conf/catalina.properties
(The lib directory at this level IS working.)

DEMARCATION 1 / TEST1-SPECIFIC FILES -
/usr/tomcat/test1
/usr/tomcat/test1/lib+conf+webapps+…
(We need the lib directory to work.)

DEMARCATION 2 / TEST2-SPECIFIC FILES -
/usr/tomcat/test2
/usr/tomcat/test2/lib+conf+webapps+…
(We need the lib directory to work.)

The only truly active catalina.properties file we have right now in working order (at the time of this posting) is in / on the primary level inside the conf directory and it has the following uncommented lines:

package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans.
package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.
common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar
server.loader=
shared.loader=
tomcat.util.buf.StringCache.byte.enabled=true

Do any of you have any idea(s) how to make this work? And please forgive me if this should have been posted in the server area–I posted it here because I believed it would fetch a bigger audience in the Java section (it always seems like the server area takes longer for responses versus the Java forum).
Mods: Feel free to move it in any event. :slight_smile:

hi Wolf 22,

some things I want to check -
how exactly are you starting the instances?
did you use the CATALINA_BASE environment variable as part of your startup script?

thanks,
Jurn

Hi, Jurn.

I’m using a startup script to start the instances. Inside this script file is the following code:


#!/bin/bash
#
# tomcat
#
# chkconfig: 345 96 30
# description:  Start up the Tomcat servlet engine.

# Source function library.
. /etc/init.d/functions


RETVAL=$?
export CATALINA_BASE="/usr/tomcat/wolf22"
export CATALINA_HOME="/usr/tomcat/tomcat-home"
#export CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8082 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmx$

case "$1" in
 start)
        if [ -f $CATALINA_HOME/bin/startup.sh ];
          then
            echo $"Starting Tomcat"
            /bin/su tomcat -c $CATALINA_HOME/bin/startup.sh
        fi
        ;;
 stop)
        if [ -f $CATALINA_HOME/bin/shutdown.sh ];
          then
            echo $"Stopping Tomcat"
            /bin/su tomcat -c $CATALINA_HOME/bin/shutdown.sh
        fi
        ;;
 *)
        echo $"Usage: $0 {start|stop}"
        exit 1
        ;;
esac

exit $RETVAL

What I do to use this script file is “sh tomcat_wolf22_instance [start / stop]”.

so for test1 and test2 instances, do you have a different startup script
with CATALINA_BASE=/usr/tomcat/test1
and CATALINA_BASE=/usr/tomcat/test2
?

We’re using 2 different test environments, each with their own startup procs:

test1:

#!/bin/bash
#
# tomcat
#
# chkconfig: 345 96 30
# description:  Start up the Tomcat servlet engine.

# Source function library.
. /etc/init.d/functions


RETVAL=$?
export CATALINA_BASE="/usr/tomcat/test1"
export CATALINA_HOME="/usr/tomcat/tomcat-home"
export CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8082 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticat$

case "$1" in
 start)
        if [ -f $CATALINA_HOME/bin/startup.sh ];
          then
            echo $"Starting Tomcat"
            /bin/su tomcat -c $CATALINA_HOME/bin/startup.sh                 
        fi
        ;;
 stop)
        if [ -f $CATALINA_HOME/bin/shutdown.sh ];
          then
            echo $"Stopping Tomcat"
            /bin/su tomcat -c $CATALINA_HOME/bin/shutdown.sh
        fi
        ;;
 *)
        echo $"Usage: $0 {start|stop}"
        exit 1
        ;;
esac

exit $RETVAL

test2:

#!/bin/bash
#
# tomcat
#
# chkconfig: 345 96 30
# description:  Start up the Tomcat servlet engine.

# Source function library.
. /etc/init.d/functions


RETVAL=$?
export CATALINA_BASE="/usr/tomcat/test2"
export CATALINA_HOME="/usr/tomcat/tomcat-home"
export CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8081 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticat$

case "$1" in
 start)
        if [ -f $CATALINA_HOME/bin/startup.sh ];
          then
            echo $"Starting Tomcat"
            /bin/su tomcat -c $CATALINA_HOME/bin/startup.sh
        fi
        ;;
 stop)
        if [ -f $CATALINA_HOME/bin/shutdown.sh ];
          then
            echo $"Stopping Tomcat"
            /bin/su tomcat -c $CATALINA_HOME/bin/shutdown.sh
        fi
        ;;
 *)
        echo $"Usage: $0 {start|stop}"
        exit 1
        ;;
esac

exit $RETVAL

Here’s the “base” startup.sh script:

# Better OS/400 detection: see Bugzilla 31132
os400=false
darwin=false
case "`uname`" in
CYGWIN*) cygwin=true;;
OS400*) os400=true;;
Darwin*) darwin=true;;
esac

# resolve links - $0 may be a softlink
PRG="$0"

while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \\(.*\\)$'`
  if expr "$link" : '/.*' > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done

PRGDIR=`dirname "$PRG"`
EXECUTABLE=catalina.sh

# Check that target executable exists
if $os400; then
  # -x will Only work on the os400 if the files are:
  # 1. owned by the user
  # 2. owned by the PRIMARY group of the user
  # this will not work if the user belongs in secondary groups
  eval
else
  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then          
    echo "Cannot find $PRGDIR/$EXECUTABLE"
    echo "This file is needed to run this program"
    exit 1
  fi       
fi          

exec "$PRGDIR"/"$EXECUTABLE" start "$@"