Eclipse Remote Debugging for Windows XP
Note: thanks to Scott Amerson of UC Davis for these instructions.
Assumptions
- Windos XP, SP2 environment
- Java 1.4.2 installed
- Tomcat 5.5.x installed together with Compat *.jar
- Maven installed and build.properties defined
- Eclipse 3.1.x installed
- MyEclipse 4.0.x installed (optional)
Setup
1. Environment: set JPDA variables as Environment variables
Set the Java Debug Wire Protocol (JDWP) for the connection and the port the debugger will use to communicate with the JVM, typically port 8000.
Set the following Environment Variables (either user or system) for debugging by right clicking on My Computer--> Properties --> Advanced Tab --> Environment Variables
JPDA_TRANSPORT=dt_socket;
JPDA_ADDRESS=8000
2. Tomcat: start in debug mode
Go to your TOMCAT_HOME\bin directory via Windows Explorer, and type:
(make sure your Tomcat\bin directory contains the catalina.bat script from the Tomcat source)
catalina jpda start
3. Eclipse: set breakpoint(s) in code and switch to Debug Perspective
Debug Perspective: Window > Open Perspective > Other > Debug
Click on Bug icon, click Debug...
and launch debug configuration wizard. Select Remote Java Application
, click New
and define the following settings:
- Connect
- Name: SakaDebug
- Project: leave blank
- Connection Type: Standard (Socket Attach)
- Host: localhost
- Port: 8000 (as defined above)
- Source
- Click
Add
and selectJava Project
icon - Click
Select all
projects (deselect local database project) - Uncheck
Add exported entries of selected projects
(otherwise references to MAVEN_REPO, ECLIPSE_HOME, etc. are added)
#Common
#*Stay with defaults
- Click
- Click
Apply
(debug session should start, otherwise click Debug icon and click on named debug profile)
Sample debug sessions
Exampe I: Legacy-service walkabout
Set a breakpoint in org.sakaiproject.service.legacy.user.cover.UserDirectoryService
, specifically in method:
public static org.sakaiproject.service.legacy.user.User getCurrentUser()
Set a breakpoint in org.sakaiproject.component.legacy.realm.DbRealmService.java
public Set unlockRealms(String userId, String lock)
Change to Debug perspective, click Debug icon and select named debug profile to start debug session.
Example II: Adding a user
Set a breakpoint in the UserDirectoryService.java
public static org.sakaiproject.service.legacy.user.User addUser(...) throws org.sakaiproject.exception.IdInvalidException, org.sakaiproject.exception.IdUsedException, org.sakaiproject.exception.PermissionException
Change to Debug perspective, click Debug icon and select named debug profile to start debug session.