DID NOT WORK >> Set as system environment variable: I had set the environment variable in my mac bash_profile
, however, Tomcat did not see that variable.
DID NOT WORK >> setenv.sh: Apache's recommendation was to have user-defined environment variables in setenv.sh
file and I did that.
THIS WORKED!! >> After a little research into Tomcat startup scripts, I found that environment variables set using setenv.sh
are lost during the startup. So I had to edit my catalina.sh
against the recommendation of Apache and that did the trick.
Add your -DUSER_DEFINED
variable in the run command in catalina.sh
.
eval exec "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
-classpath "\"$CLASSPATH\"" \
-Djava.security.manager \
-Djava.security.policy=="\"$CATALINA_BASE/conf/catalina.policy\"" \
-Dcatalina.base="\"$CATALINA_BASE\"" \
-Dcatalina.home="\"$CATALINA_HOME\"" \
-Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
-DUSER_DEFINED="$USER_DEFINED" \
org.apache.catalina.startup.Bootstrap "$@" start
P.S: This problem could have been local to my computer. Others would have different problems. Adding my answer to this post just in case anyone is still facing issues with Tomcat not seeing the environment vars after trying out all recommended approaches.