Set environment variable in shell script/access in Tomcat Application

Anand Soni picture Anand Soni · Apr 14, 2012 · Viewed 15.9k times · Source

I want to add and environment variable which can access by my tomcat web-app. I have gone through this link but i want to set environment variable in root user. How to do that?

Answer

gsaslis picture gsaslis · Dec 11, 2014

According to the docs (http://tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt) you should set all env vars in $CATALINA_HOME/bin/setenv.sh

EDIT: For completeness, I guess it's worth mentioning that even though this is the recommended way, the docs above state that:

By default the setenv script file is absent. If the script file is present both in CATALINA_BASE and in CATALINA_HOME, the one in CATALINA_BASE is preferred.

In case it is absent, you might also want to look for env vars in:

  • /etc/tomcat/tomcat[67].conf (suse) or
  • /etc/default/tomcat[67].conf (e.g. ubuntu) or
  • /etc/sysconfig/tomcat[67].conf (rhel, fedora)