This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

best place to put JAVA_OPTS setting for Tomcat memory

 
Charles Owen
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am running Tomcat 6.0.24 on SuSE Linux. Where's the best place to put my JAVA_OPTS setting for setting the memory heap size?

Can someone give me an example? The idea is to set it somewhere before Tomcat starts, right?

I can see a few places to put it.

Tomcat6.conf
catalina.sh

I have no setenv.sh.

Thanks
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18020
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setenv.sh/setenv.bat are not supplied with Tomcat, but if you add one, Tomcat will use it. It's the best place to put stuff like that, since you totally own that file and don't have to modify any of Tomcat's own files, which can simplify maintenance and assist in intrusion detection (the original Tomcat files would retain their original text/checksum values).

If Tomcat (catalina) detects the presence of a setenv file, it will execute it to set up the environment to be used for the requested catalina operation. This file must have read access rights for the Tomcat user, and I recommend execute rights (where applicable) as well, although I don't think they're actually mandatory.
 
Charles Owen
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response. I will give this a whirl.

 
Charles Owen
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I noticed that my tomcat start up script explicitly specifies tomcat6.conf as the configuration file, so I think I should put the JAVA_OPTS setting there. This may be a SuSE Linux convention.

# Get the tomcat config (use this for environment specific settings)
TOMCAT_CFG="/etc/tomcat6/tomcat6.conf"

When I set the JAVA_OPTS, do I also have to export it?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18020
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SuSe is a lot like Red Hat, and although I usually install Tomcat as a straight UNZIP from tomcat.apache.org, I've also worked on occasion with RPM-based installs. Main reason I don't use RPM for Tomcat routinely is that there's not always an RPM available - especially for up-to-date releases of Tomcat.

What the RPM mostly does is make Tomcat friendlier to the Linux Filesystem Hierarchy Standard, which it does by the magic of softlinks so that Tomcat's logs appear in /var/logs, the temp appears in /var/lib, config appears in /etc, and so forth. Obviously your RPM does just a little bit more than that. I think that tomcat6.conf is actually sourced by an init script which is a third-party addition to the package (take a look at /etc/init.d/tomcat6).

conf files do not require exports. Aside from just being a general Unix/Linux rule, in this particular case, that's because the conf file will be sourced by the init script and then inherited by the catalina script that the init script invokes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic