Thursday 10 April 2014

Remote debugging using Tomcat with eclipse


Remote debugging using Tomcat with eclipse
The Java debugger has a client/server design so that it can be used to debug programs that run locally (on the same workstation as the debugger) or remotely (on another computer on the network).
Local debugging:
Local debugging is the simplest and most common kind of debugging.  After you have finished editing and building your Java program, you can launch the program on your workstation using the menu item on the workbench.  Launching the program in this way will establish a connection between the debugger client and the Java program that you are launching.  You may then use breakpoints, stepping, or expression evaluation to debug your program.
Remote debugging:
The client/server design of the Java debugger allows you to launch a Java program from computer on your network and debug it from the workstation running the platform.  This is particularly useful when you are developing a program for a device that cannot host the development platform.  It is also useful when debugging programs on dedicated machines such as web servers. 
Steps:
  1. Stop your tomcat if it is in running mode.
  2. Go to Tomcat/webapp/bin. You will find a file catalina.bat (windows)/ catalina.sh (UNIX and Linux).
  3. Catalina.sh have this entry:
JPDA_ADDRESS = 8080
This port number is use for remote debugging. 8080 is default port and you can change it if required.
Write this command on UNIX command interpreter: catalina.sh jpda start
You will see something like this “INFO: Server startup in 4955 ms”.
Now, go to eclipse
Click on debug pick list icon and you will menu like this:



Now select Debug Configurations…
You well get a new window like this:



Now right click on “Remote Java Application” and select “new”.
Debug configuration window now looks like this:



Select an entry for Name field.
Select desired project from Browse button.
Enter Host: (Host name of the machine where tomcat will run.) and valid port number.
Select Apply and click Debug.  
Now you can debug your application as you usually debug on local machine.

[Note: Remote debugging may be quite slow as compared to debugging on local machine]

Sources: http://help.eclipse.org/

No comments:

Post a Comment