Remote debugging info
Here are the steps required to connect a remote debugger to the ZCS server. On the server:
This returns the current JVM options that we pass to Tomcat.
(Remove spaces before "suspend=n". I have no idea why the forum app puts them there).
zmlocalconfig -e tomcat_java_options="<current JVM options> -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n"
If you need to debug code that runs during server startup, specify suspend=y instead. Note that if you do this, server startup will hang until a remote debugging session attaches to it. Feel free to use a different port number if you like.
Restart the server and make sure you're still able to read mail.
On the client:
- Make sure that your source is synced to the same timestamp as the server build.
- In Eclipse, choose the Run / Debug... menu option.
- Choose Remote Java Application and click the New button.
- Set Name to "Remote", Host to the hostname and Port to 8000.
- Click Close.
Now if you ever need to debug the server, click on the down arrow next to the bug icon and choose "Remote". If you don't want to use Eclipse, connect to the server on port 8000 using any standard JDWP debugger.
I just realized that our tomcat launcher is rejecting the -Xdebug JVM option, so the directions above will not work. I'll post a followup message once I figure out an elegant way around this.
If you follow the instructions above, an error message appears in catalina.out:
zmtomcatstart: error: JVM option: -Xdebug: not allowed
As a workaround, you can:
1. edit ZimbraNative/src/launcher/zmtomcatstart.c
2. add -Xdebug and -Xrunjdwp to the AllowedJVMArgs array
3. rebuild and install zmtomcatstart
tomcat then listens on port 8000 and you are happily debugging.
If you don't want to recompile C source, you can start tomcat with these parameters and also attach remotely. (This is for 3.1.4 BTW)
/opt/zimbra/jdk1.5.0_06/bin/java -Xms303m -Xmx303m -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n -client -XX:NewRatio=2 -Dcatalina.base=/opt/zimbra/apache-tomcat-5.5.15 -Dcatalina.home=/opt/zimbra/apache-tomcat-5.5.15 -Djava.io.tmpdir=/opt/zimbra/apache-tomcat-5.5.15/temp -Djava.library.path=/opt/zimbra/lib/jars -Djava.endorsed.dirs=/opt/zimbra/apache-tomcat-5.5.15/common/endorsed -classpath /opt/zimbra/apache-tomcat-5.5.15/bin/bootstrap.jar:/opt/zimbra/apache-tomcat-5.5.15/bin/commons-logging-api.jar org.apache.catalina.startup.Bootstrap start