Translate

martes, 1 de julio de 2014

Remote Debug in tomcat 6 and 7

Título: Debug remoto sobre servidor de aplicaciones Tomcat 6 y 7.

What happends when we can´t install and application in a local tomcat in order to debug some issue o bug?

The answer is easy, remote debug y the key. It allows you to debug the code in the same way like if your web application was installed in your machine.

Note: You have to have installed in your local machine the same code that is in the remote machine to do properly remote debug.

Configuration:

1 - Remote server´s configuration: The remote server have to be setted with params to determine a port (8000 for example) where the server will listen to a remote debug connection.

When you run tomcat you have to pass to virtual machine this params:

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

The easy way to do it is to edit the file [tomcat_installation]\bin\setenv.bat and add this lines

set DEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
set JAVA_OPTS=%JAVA_OPTS% %DEBUG%              

2 - Local configuration (eclipse):

You have to create a Remote Java Application in Debug Configurations:



With the next options, setting a socket with the remote server host and port 8000 .



don´t forget to select the Project where the source code is located.

Happy Debug!!!