Skip to content

Remote Debugging with Eclipse and Tomcat

June 25, 2007

When I first join this new company as my 2nd job, I was quite amazed by the fact that they are still using System.out.println to debug an application. Wait! There is nothing wrong using the sysout to debug application, but why not move to something faster, more efficient way? What if the developer forgot the remove the sysout line from their application? Wouldn’t it be messy and time consuming?

Having to set up my own machine to develop application using apache-tomcat-6.0.10, Java 1.5 and Eclipse 3.1.1, I took the opportunity to setup the environment so that I could use remote debugging, which enable easier and faster steps when fixing bugs.

Below are the steps to configure your machine for remote debugging.

Please note that the configuration is only tested for Win XP.

(1) Configure the catalina.bat file in apache-tomcat.

-You can find the catalina.bat file in your apache-tomcat installation folder/bin. Example, in my case, it would be D:/apache-tomcat-6.0.10/bin

-Edit the file using notepad and go to the line<set JPDA_TRANSPORT>. Set it to <set JPDA_TRANSPORT=”dt_socket”>

-And also set the port to 8000 <set JPDA_ADDRESS=”8000″>

-You can always set the JPDA_ADDRESS to another port. Just make sure that the port number is not in used. To check,hit START=> RUN => type cmd => type netstat.
All running ports will be displayed.

(2) Configure remote debugging in Eclipse.

-Click on the green beatle icon on top of the tools, you’ll be able to see this pop up.

-At Remote Java Application, click new and configure the settings.

-Type localhost at Host and 8000 as the port. Please note that the port must be the same with the JPDA_ADDRESS in catalina.bat file.

-Browse the application that you would like to debug.

(3) Start your server.

-To start the server, just type catalina jpda start

-Once started, you’ll be able to see the dt_socket on your console.

-You can also check whether the port has been started using the netstat command.

(4) Start remote debugging, Place a line break.

-Go to step (2). Click on DEBUG.

-Go to the method that you would like to debug.

-Double click on the left panel. You’ll be able to see a line break with a tick symbol.

(5) Debug

-Once your application hit the method, the eclipse will enable debugging. It’ll stop at the line break (which you had define earlier).

-Switch to Debug view.

-Hit F6 to go thru the codes.

(6) Stop debug mode

-To stop the debug mode, just click on the disconnect button.

(7) Stop server

-To stop the server, just type catalina stop

Seems tidious? But its not as hard as you think. Once you have your hands on it, you’ll be amazed what this Eclipse has offered!

From → Eclipse

27 Comments
  1. Hey, dude
    thanks alot.
    It was really helpful.
    thanks once agian.

  2. Anjan permalink

    ThanQ very much,
    Really it is helpful much to me

  3. welcome, i’m glad i helped

  4. K ANIL permalink

    By following this procedure , i am getting an error called, remote VM connection failed and connection refused. what is the problem can u rectify this problem

  5. wow… good job!! had you try log4j? logging important message such as program bootstrapping log in a log file is useful for production trace or debugging…

  6. Anonymous permalink

    very well explained

  7. Yea, JJ. I did try Log4J

  8. Francesco permalink

    Thank, that’s was very concise and understandable

  9. jAY permalink

    Good article and works fine… thanks a lot… 🙂

  10. Welcome Francesco & Jay. Thanx for dropping by

  11. Pete permalink

    You r the man…

    After breaking my head on all the other articles out there – sanity at last!

    Well done 🙂

  12. NDM permalink

    This is really one of the best article i have ever seen on web for configuring Remote Debug from an IDE with application server as Tomcat.

    Great Job!!!

  13. thankz for the good comments.. now, i’m a happy person. ahha

  14. Thanks dude. You article was really helpful. You are the man…… 🙂

  15. swanand permalink

    hey thnx a lot .. this explaination is really gr8 and easy to understand…

  16. Balwinder Kumar permalink

    Very nice and self explanatory article, I will be glad if you also include linux as well.

  17. I am using Tomcat6, and I get this remote VM connection failed and connection refused. I can not see catalina.bat anywhere in my tomcat folder. I can start in using tomcat6 and tomcat6w applications

  18. PKG permalink

    Dude..Nice Job.Very Very good article

    thanks

  19. Anonymous permalink

    Thanks buddy…worked like a charm

  20. vinay permalink

    awesome, very very helpful

  21. Rafael Ríos permalink

    Great Help.
    Thanks

  22. dude u rock

  23. Chandrashekar permalink

    Hi, When in insert a break point it is giving an error like “Unable to insert breakpoint”, I think this is because compiled java classes doesnt have line numbers. but how to avoid that error?

  24. Atul_shukla permalink

    By following this procedure , i am getting an error called, remote VM connection failed and connection refused. what is the problem can u rectify this problem

  25. rizky permalink

    Good sharing knowledge. Thanks a lot

  26. Anonymous permalink

    Great explanation… thanks a lot

  27. Hey, great site, speaking of Word-press plugins is anyone recommend a easy to install Clickbank plugin? A cheap plugin would be even better – Best wishes

Leave a reply to Chandrashekar Cancel reply