Remote debugging info

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
Advanced member
Advanced member
Posts: 78
Joined: Fri Sep 12, 2014 9:55 pm

Remote debugging info

Postby bburtin » Tue Jan 10, 2006 6:54 pm

Here are the steps required to connect a remote debugger to the ZCS server. On the server:

zmlocalconfig tomcat_java_options

This returns the current JVM options that we pass to Tomcat.

zmlocalconfig -e tomcat_java_options=" -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n"

(Remove spaces before "suspend=n". I have no idea why the forum app puts them there).

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.

Advanced member
Advanced member
Posts: 78
Joined: Fri Sep 12, 2014 9:55 pm

Remote debugging info

Postby bburtin » Wed Jan 11, 2006 1:34 pm

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.
Advanced member
Advanced member
Posts: 81
Joined: Fri Sep 12, 2014 10:10 pm

Remote debugging info

Postby ljm » Wed May 24, 2006 3:35 am

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.
Advanced member
Advanced member
Posts: 51
Joined: Fri Sep 12, 2014 10:06 pm

Remote debugging info

Postby kiwicmc » Mon Oct 16, 2006 3:43 pm

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.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

Posts: 41
Joined: Sat Sep 13, 2014 3:11 am

Remote debugging info

Postby a1ex » Wed Oct 01, 2014 6:12 pm


Do you know how to start ZCS 7 in the same debug mode ?
User avatar
Greg Solovyev
Posts: 12
Joined: Wed Mar 05, 2014 11:30 am

Remote debugging info

Postby Greg Solovyev » Wed Oct 01, 2014 6:38 pm

ZCS 7 uses Jetty (we switched to Jetty from Tomcat in version 5) There's a way to run and debug jetty with jetty-ant plugin. Basically you run jetty as an ant task and use Eclipse remote debugging with jetty-ant plugin.

To use jetty-ant, first you need to setup a shell for service webapp.
Go to ZimbraServer directory and run:

ant -buildfile jetty-ant.xml jetty.webinf

You'll only need to do this once unless either you clean the build directory or changes things such as web.xml.

To launch jetty, run the following:

ant -buildfile jetty-ant.xml

Note that due to a jetty-ant-plugin bug you need to set this env var:


To debug, run the target with ANT_OPTS like this:

ANT_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Djava.library.path=/opt/zimbra/lib -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y" ant -buildfile jetty-ant.xml

This will start jetty-ant plugin but blocks on listening on port 4000.

If you run into Out Of Memory errors, you may also want to increase the memory size by adding PermSize and MaxPermSize options.

The command line will look like this with additional memory allocation options:

ANT_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Djava.library.path=/opt/zimbra/lib -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y, -XX:PermSize=64M -XX:MaxPermSize=256M" ant -buildfile jetty-ant.xml

Now go to Eclipse and select Run/Debug... and right click on Remote Java Application to "New" a configuration. Call it anything you want such as "jetty-ant". Select any project as the debug project. Set Host/Port to localhost and 4000. Then go to Source tab and add all the projects you are interested in debugging.

Apply the configuration settings and press "Debug". This will attach the debugger to the jetty-ant process. You can see activity in the
previously blocked jetty-ant console, and debugger will stop at your break points.

To shutdown jetty, simply send Ctrl+C to the console window where you are running jetty-ant.

Posts: 41
Joined: Sat Sep 13, 2014 3:11 am

Remote debugging info

Postby a1ex » Mon Oct 06, 2014 4:34 pm

Hi Greg!

Thank you very much for your answer!

I'll try your steps once I managed to build Zimbra FOSS.

Return to “Developers”

Who is online

Users browsing this forum: No registered users and 5 guests