How to set CATALINA_OPTS in Tomcat’s setenv.sh

How to set CATALINA_OPTS in Tomcat’s setenv.sh

How to set CATALINA_OPTS for the JVM used by Tomcat.

Write CATALINA_OPTS in $CATALINA_BASE/bin/setenv.sh or $CATALINA_HOME/bin/setenv.sh.

In my environment, it was found in the following.

/opt/tomcat/bin/setenv.sh

In catalina.sh, setenv.sh is loaded if present.

catalina.sh

if [ -r "$CATALINA_BASE/bin/setenv.sh" ]; then
  . "$CATALINA_BASE/bin/setenv.sh"
elif [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
  . "$CATALINA_HOME/bin/setenv.sh"
fi

Here is an example of setting system properties with the -D option to the JVM.

setenv.sh

CATALINA_OPTS=" \
-Dbtm.root=$CATALINA_HOME \
-Dbitronix.tm.journal.disk.logPart1Filename=/opt/tomcat/logs/btm1.log \
-Dbitronix.tm.journal.disk.logPart2Filename=/opt/tomcat/logs/btm2.log \
-DPARAM1=true \
-DPARAM2=1 \
-DYAHOO_HOME=https://www.yahoo.co.jp \
"

setenv.sh does not have to be a shell; setting variables in catalina.sh should be avoided and should be in setenv.sh.

コメント

Discover more from 株式会社CONFRAGE ITソリューション事業部

Subscribe now to keep reading and get access to the full archive.

Continue reading

Copied title and URL