Remote debugging Tomcat with Eclipse
16 Comments Published October 4th, 2005 in Eclipse, Java, Web Tags: .Today I tried to use remote debugging with Eclipse and Tomcat.
I usually use a Tomcat Sysdeo Plugin to run Tomcat inside Eclipse, but today I faced remote debugging.
To run tomcat in remote debugging you can start it with command
catalina jpda start
But this will start remote debugging using shared memory, and Eclipse, as far as I know, does not support shared memory as transport for deubugging.
The alternative is to use a socket as transport for JPDA.
You simply set some enviroment variable that will be checked by catalina startup script, as in following example:
set JPDA_TRANSPORT=dt_socket set JPDA_ADDRESS=5050 ... then you can run ... D:\Java\jakarta-tomcat-5.5.7\bin>catalina jpda run ...or... D:\Java\jakarta-tomcat-5.5.7\bin>catalina jpda start
This tells catalina script to use socket transport for debugging and to listen on port 5050. If you don't specify the port, it will be assigned randomly.
When you start tomcat, you'll see some messages on console saying that debugging socket is listening:
D:\Java\jakarta-tomcat-5.5.7\bin>catalina jpda run
Using CATALINA_BASE: D:\Java\jakarta-tomcat-5.5.7
Using CATALINA_HOME: D:\Java\jakarta-tomcat-5.5.7
Using CATALINA_TMPDIR: D:\Java\jakarta-tomcat-5.5.7\temp
Using JAVA_HOME: d:\Java\jdk1.5.0_04
Listening for transport dt_socket at address: 5050
4-ott-2005 18.26.11 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
4-ott-2005 18.26.11 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1162 ms
4-ott-2005 18.26.11 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
4-ott-2005 18.26.11 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.7
4-ott-2005 18.26.11 org.apache.catalina.core.StandardHost start
Now it's time to connect to that socket using Eclipse: see following picture.
On "Connection Properties" you can configure a remote VM that you want to debug. Then place your breakpoints and run the shown launch configuration.
Shared memory is easier to be used: with tomcat you don't have to set up environment variables, and for IDE supporting it (I used this with IntelliJ), you only need to specify the name of the shared space. This won't work if the VM to debug is on a remote computer but can be helpful anyway. I tried to find shared memory support in Eclipse but I didn' find it, and I believe it doesn't have.
Remote debugging is more useful when you have to attach to a running instance on a remote server on which the bug is alive. Shared memory support lack is not that problem.
One thing that you cannot do running programs inside Eclipse under Windows is to get a Thread dump. On Windows you can get a Thread Dump pressing CTRL+Break in the DOS console, but this doesn't work on Eclipse console. On Linux you can use "kill -3", and I think this work even running processes in Eclipse. Maybe it's possible also in Windows, using some esotic tool, but I don' know... also I don't know if Windows supports several kill signals.
16 Responses to “Remote debugging Tomcat with Eclipse”
- 1 Pingback on Mar 13th, 2008 at 07:24
- 2 Pingback on Jul 24th, 2008 at 14:35
- 3 Pingback on Jan 27th, 2011 at 12:11
Leave a Reply
Search
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Sep | Nov » | |||||
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 | ||||||
Archives
Categories
- Android (3)
- Apple (27)
- Books (7)
- Eclipse (14)
- Errors (4)
- Firefox (7)
- Git (2)
- Hardware (17)
- Horror Code (8)
- Internet (21)
- Java (102)
- JavaScript (9)
- Life, universe and everything (46)
- Lifehacks (25)
- Linux (51)
- Opinions (26)
- OSX (6)
- Python (1)
- Software (31)
- Speeches and Conferences (8)
- Unix (4)
- Web (23)
- Windows (19)
Tag Cloud
Android apple architecture Bash configuration CSS Development Düsseldorf Eclipse Git Google Hardware hdr How-To Java JAXB job junit Karmic Linux lion MacBook music Open Source Opinion oracle OSX patterns Pitfalls Practices Resume Security Software Suspend TDD Testing tip tonemapped Tricks Ubuntu unix video Web Workaround XML
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.
Blog License
Blogs I like
Books on the desk
Friends' Blogs
- Antonio Terreno & Valter Bernardini
- Bruno Bossola
- Daniele Galluccio
- Domenico Ventura
- Ed Schepis
- Fabrizio Gianneschi
- Luca Grulla
- Luigi Zanderighi
- Marcello Teodori
- Mida Boghetich
- Muralidharan Chandrasekaran
- Piero Ricca
- Renzo Borgatti
- Simone Bordet
- Simone Bruno
- Uberto Barbini
- Valvolog
- Webtide blogs (Greg Wilkins & Jan Bartel)
Links




















the steps and the explanation provided are very vague. isnt there a site that gives a detail view into the issue.
i m trying to debug a tomcat in the linux box from a win xp box. when i put the paramters as specified here the tom cat doesnt start up at all.! any ideas
do we need to include some jar in classs path or any other??
cheers,
ravi
At last I can remote debug my web app in tomcat 5.5 with eclipse – why are these options not made more visible or scripted? so simple when running under JBoss but tomcat on its own seems to make life that little bit more difficult.
Excellent post! I am doing schoolwork with eclipse ganymede and the buggy bitch will not deploy my project properly to the internal server and will not connect to the internal server even tho it seems to be running. Matter of fact it will not connect to any web service internally: can’t access help either. I love eclipse 18M lines of code delivered on time and full of bugs.
Hey,
That was very helpful. Better than all publications on debugging i see lately.
Thanks!
Regards,
D
Hi I used your procedure to debug a webservice (axis2 and tomcat). I installed breakpoint on sekeleton (webservice side) but I receive this message: “Unable to install breakpoint in ‘project name’ due to missing line number attributes…”
I checked on eclipse window/preference/java/compiler and all the options are correctly flagged.
Can anyone help me?
Thanks
Hi Pedro.
Probably your class files are compiled without debugging information. Ensure that javac (java compiler) is not invoked specifying any option to suppress debug informations in class files. Check also ant/maven or the other tools you are using to compile your classes. Definitely the problem is in the class files.
Hi Luigi, I check my build.xml file (I generate the .class by ant) as you suggested and tag had the field debug=”false”. Now this field is “true” and all works: now I can debug in remote… Thank you very much….
Thanks, that was very helpful !!!
Excellent post..I was able to debug my stuff.Keep it up..
Hi,
Is is possible that at a time more than one person can do remote debugging on same server machine ???
If yes , please tell me how can we do this… my id… vishal12d@gmail.com
Hello,
I try to apply to my program but I have a connection timed out when I run the remote application.
Here is what I do:
1) In Eclipse, I open the menu Debug Configurations, I add the argument: « -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8080 » on the Tomcat.
2) I run Tomcat in debug mode
3) I create a new Remote Application (Host : localhost Port : 8080)
4) I open internet and type the address http://localhost:8080/eurogesTrunk/ to run my application
5) I run my application
6) I run the remote application
Et after a few seconds, I have a connection timed out.
Can you help me?
please see the bellow link for more information
https://confluence.sakaiproject.org/display/BOOT/Setting+Up+Tomcat+For+Remote+Debugging
The info is elpful to me, especially the way to check if tomcat is started correctly with debug on. Thanks!