How do I configure Tomcat to support remote debugging?

Posted: March 29, 2012 in IT and Programming Stuff
Tags: ,

Copy paste dari sini ~> http://wiki.apache.org/tomcat/FAQ/Developing

The short answer is to add the following options when the JVM is started:

-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

There are a number of ways you can do this depending on how you normally start Tomcat:

  • If you are using shell scripts to start Tomcat, start it with the following command:
catalina jpda start

It will start Tomcat so that a remote debugger can be connected to port 8000.

The above mentioned options can be provided by setting certain environment variables. See the comments at the top of catalina.sh or .bat file for details.

For example, the port number and JPDA transport implementation can be set with JPDA_ADDRESS=8000 and JPDA_TRANSPORT=dt_socket.

  • If you run Tomcat using service wrapper, add the above JVM options before any other JVM options. Check the documentation for the service wrapper to determine how to set JVM options.
  • If you start Tomcat from within an IDE, check the documentation for the IDE to determine how to set the required JVM options.

The port does not need to be set to 8000, it may be any value appropriate for your system.

Whilst this is very useful in development it should not be used in production because of both security and performance implications.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s