Adding java_opts params in Tomcat 6

谁都会走 提交于 2019-12-04 14:43:01

问题


I have a requirement to add -DAPP_ENCRYPTION_PASSWORD in Tomcat to start an application. Can any one point exactly where to add this parameter? And how?


回答1:


It all depends on how you plan to start Tomcat. Tomcat itself wants to be run a shell script that's typically located at $TOMCAT_HOME/bin/catalina.sh (there's an equivalent .bat file for windows). Inside of that file it describes what tomcat expects for an environment. If you want to get your -DAPP_ENCRYPTION_PASSWORD system property into the startup of Tomcat, I think you just figure out how to get it set up in the environment as JAVA_OPTS and you are on your way.

If you are desperate and want to avoid setting up the environment, I suppose that you could edit catalina.sh directly.

The environment variable sequence looks like...

  1. from a command shell, change to the directory where tomcat is deployed
  2. from a command shell, change to the "bin" directory under tomcat
  3. from a command shell, set the JAVA_OPTS evironment variable like "JAVA_OPTS=-DAPP_ENCRYPTION_PASSWORD"
  4. from a command shell, start tomcat like "./startup.sh"

The output will look like...

bobk-mbp:~ bobk$ cd work/apache-tomcat-6.0.35/
bobk-mbp:apache-tomcat-6.0.35 bobk$ cd bin
bobk-mbp:bin bobk$ JAVA_OPTS=-DAPP_ENCRYPTION_PASSWORD
bobk-mbp:bin bobk$ ./startup.sh 
Using CATALINA_BASE:   /Users/bobk/work/apache-tomcat-6.0.35
Using CATALINA_HOME:   /Users/bobk/work/apache-tomcat-6.0.35
Using CATALINA_TMPDIR: /Users/bobk/work/apache-tomcat-6.0.35/temp
Using JRE_HOME:        /Library/Java/Home
Using CLASSPATH:       /Users/bobk/work/apache-tomcat-6.0.35/bin/bootstrap.jar



回答2:


The simple and preferred way to set environment variables for Tomcat is via the bin/setenv.sh script. See this: How to tune Tomcat 5.5 JVM Memory settings without using the configuration program

Or this: https://stackoverflow.com/search?q=setenv.sh



来源:https://stackoverflow.com/questions/8424804/adding-java-opts-params-in-tomcat-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!