Remote debugging Tomcat with Eclipse
Pubblicato da Luigi il 4 Ottobre 2005 in Java, Eclipse, WebToday 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.
11 Commenti a “Remote debugging Tomcat with Eclipse”
- 1 Pingback on 13 Mar 2008 alle 07:24
- 2 Pingback on 24 Lug 2008 alle 14:35
Lascia un Commento
Cerca
Calendario
| L | M | M | G | V | S | D |
|---|---|---|---|---|---|---|
| « Set | 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 | ||||||
Archivi
- Gennaio 2010 (2)
- Dicembre 2009 (1)
- Novembre 2009 (3)
- Settembre 2009 (2)
- Agosto 2009 (4)
- Luglio 2009 (1)
- Giugno 2009 (2)
- Maggio 2009 (4)
- Aprile 2009 (2)
- Marzo 2009 (7)
- Febbraio 2009 (5)
- Gennaio 2009 (2)
- Dicembre 2008 (1)
- Novembre 2008 (8)
- Ottobre 2008 (12)
- Settembre 2008 (3)
- Agosto 2008 (2)
- Luglio 2008 (6)
- Giugno 2008 (16)
- Maggio 2008 (2)
- Aprile 2008 (3)
- Marzo 2008 (6)
- Ottobre 2007 (1)
- Settembre 2007 (1)
- Agosto 2007 (5)
- Luglio 2007 (6)
- Giugno 2007 (6)
- Maggio 2007 (1)
- Marzo 2007 (1)
- Febbraio 2007 (2)
- Gennaio 2007 (1)
- Dicembre 2006 (2)
- Novembre 2006 (4)
- Ottobre 2006 (7)
- Settembre 2006 (1)
- Agosto 2006 (2)
- Luglio 2006 (6)
- Giugno 2006 (3)
- Febbraio 2006 (1)
- Gennaio 2006 (1)
- Dicembre 2005 (5)
- Novembre 2005 (2)
- Ottobre 2005 (2)
- Settembre 2005 (7)
- Agosto 2005 (2)
- Luglio 2005 (8)
- Giugno 2005 (12)
Categorie
- Books (7)
- Eclipse (10)
- Errors (2)
- Firefox (7)
- Hardware (14)
- Horror Code (8)
- Internet (17)
- Java (85)
- JavaScript (8)
- Life, universe and everything (29)
- Linux (44)
- Mac (18)
- Software (25)
- Speeches and Conferences (8)
- Web (19)
- Windows (16)
Ultimi Post
- Syntactic sugar and Java arrays.
- 3G USB Stick on Ubuntu
- Ipod touch with Linux
- Karmic and Luks: USB drive encryption made (almost) easy
- Suspend/Resume in Karmic /2
- Suspend/Resume problem in Ubuntu Karmic 9.10 running on MacBook Pro 5.1
- MacBook International Keyboard and Linux
- Mighty Mouse: reverse horizontal scrolling workaround on Ubuntu Linux 9.04
- Skype 2.1.0.47 beta released, and amd64 packages available!
- Linux RAM Disks
My open source projects
Blog License
Blogs I like
Friends' Blogs
- Antonio Terreno & Valter Bernardini
- Bruno Bossola
- Daniele Galluccio
- Domenico Ventura
- Ed Schepis
- Fabrizio Gianneschi
- Filippo Diotalevi
- JavaJournal.it Blog
- Luca Grulla
- Luigi Zanderighi
- Marcello Teodori
- Mida Boghetich
- Muralidharan Chandrasekaran
- Piero Ricca
- Renzo Borgatti
- Simone Bordet
- 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..