Remote Debugging with Eclipse and Tomcat
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!
Hey, dude
thanks alot.
It was really helpful.
thanks once agian.
ThanQ very much,
Really it is helpful much to me
welcome, i’m glad i helped
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
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…
very well explained
Yea, JJ. I did try Log4J
Thank, that’s was very concise and understandable
Good article and works fine… thanks a lot… 🙂
Welcome Francesco & Jay. Thanx for dropping by
You r the man…
After breaking my head on all the other articles out there – sanity at last!
Well done 🙂
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!!!
thankz for the good comments.. now, i’m a happy person. ahha
Thanks dude. You article was really helpful. You are the man…… 🙂
hey thnx a lot .. this explaination is really gr8 and easy to understand…
Very nice and self explanatory article, I will be glad if you also include linux as well.
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
Dude..Nice Job.Very Very good article
thanks
Thanks buddy…worked like a charm
awesome, very very helpful
Great Help.
Thanks
dude u rock
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?
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
Good sharing knowledge. Thanks a lot
Great explanation… thanks a lot
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