JAVA_OPTS set in catalina.sh not working for TOMCAT private instance

catalina, java, java-opts, tomcat, ubuntu

Solution

You are not supposed to edit the catalina.sh file - it states so in that file. Instead, to set your environmental variables, create a setenv.sh file in the same directory where catalina.sh is (called CATALINA_BASE/bin) and write your code in it.

I had to set the `JAVA_OPTS` variable myself, and I created the `bin/setenv.sh` file, set it to executable `chmod +x bin/setenv.sh` and wrote in it:

`JAVA_OPTS="$JAVA_OPTS -Xms128m -Xmx512m -server"`

which set my initial allocated memory to 128 and max memory to 512 MB. And it was working.

Problem

I have placed JVM options via JAVA_OPTS in catalina.sh in the catalina base. However, the system doesn't pick those options--I am trying to pass profiling information to set paths for project properties and logging files. I have to set the options in setenv.sh in the private instance's bin. Even the echo command that I put in catalina.sh to view the JAVA_OPTS doesn't get printed-defaults like CATALINA_BASE,etc. do get printed. Is catalina.sh even being processed? At the end of the day, my system works fine with setenv.sh. I am curious as to why JAVA_OPTS are not being picked up from catalina.sh. I am using Ubuntu 12.04 with TOMCAT 7 installed and JDK 1.7. Thanks

Original source

Related problems