Blogs
I know that some people are suggesting using the setenv.sh script to control JVM settings for tomcat.
Notably I see adding JMX configurations this way, among other things.
Be careful what you add to this script as some things, like JMX settings, will break the ability to use the shutdown scripts.
The setenv.sh script is called regardless of startup or shutdown of tomcat. If you add JMX for instance, it tries to bind the JVM's JMS server to a port. While this sounds ok, during shutdown you don't need this, plus it will cause the JVM you're starting up to pooch because the port is already bound by another JVM (the one you're trying to shutdown).
Also, simply adding these settings to catalina.sh can cause the same problem.
The solution is to isolate things you only want tomcat to have during startups. You can use this if block, right around line 188 of catalina.sh:
...
if [ "$1" != "stop" ] ; then
JAVA_OPTS="$JAVA_OPTS -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m -Xshare:off"
JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/home/some/deploy-sp/solr-1.3"
JAVA_OPTS="$JAVA_OPTS -Dexternal-properties=/home/some/portal-web/docroot/WEB-INF/src/portal-developer.properties"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote=true"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=9030"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
fi
# ----- Execute The Requested Command -----------------------------------------
...
That should allow the shutdown scripts to work again as expected.
Oh, one more thing... you don't have to add debug startup parameters to tomcat's startup scripts BTW.
i.e. -agentlib:jdwp=transport=....
Tomcat already provides a mechanism to startup up so you can connect with a debugger.
Simply start with catalina.sh instead like so:
$ ./catalina.sh jpda start
The JVM is now running with appropriate debug configuration at port 8000 by default.

