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.
|« Sep||Nov »|
- Android (3)
- Apple (30)
- Books (7)
- Eclipse (14)
- Errors (5)
- Firefox (7)
- Git (3)
- Hardware (18)
- Horror Code (8)
- Internet (21)
- Java (106)
- Life, universe and everything (45)
- Lifehacks (26)
- Linux (53)
- Opinions (26)
- OSX (11)
- OWNER API (3)
- Python (1)
- Software (35)
- Speeches and Conferences (8)
- Unix (5)
- Web (23)
- Windows (19)
Android apple architecture Bash bsd configuration CSS Development Düsseldorf framework free Git Google Hardware hdr How-To howto Java Karmic library Linux lion MacBook maven opensource Open Source Opinion os x OSX owner owner api patterns Pitfalls Practices properties Software TDD Testing tip tonemapped Tricks Ubuntu unix video Web