Sharing a Java debug session by transferring it to another user
This example shows how to share the debug session of a Java application. The following scenario can be executed if you have completed the steps in Source control scenarios (Chapter | 9, "Rational Team Concert"). If you are unsure whether the two users have the same versions of the projects imported, you can revert back to a known baseline that contains the desired sources.
To replace the contents of each user's workspace with a known baseline, perform these steps:
|
|
| Right-click My Repository Workspaces in the Team Artifacts view.
|
|
|
| Select the personal workspace of the user.
|
|
|
| Right-click Java Prototype Component.
|
|
|
| Select Replace With Æ Baseline.
|
|
|
| Select the Baseline Imported prototype.
|
|
|
| Look at the Pending Changes view.
|
|
|
| Right-click the Incoming Changes and select Accept.
|
To initiate the debug session and transfer it to another user, Lara performs the following steps:
| Open BankClient.java.
|
| Place a breakpoint on the line executeCustomerTransactions(iTSOBank);.
|
| Right-click BankClient.jav and select Debug As Æ Debug Configurations.
|
Name: RAD75 Team Debug Configuration
|
Main class: itso.rad75.bank.client.BankClient
|
In the Team tab select Add debug session to team repository.
|
Select a team repository: hostname (rcsnl-cc.rcsnl.ams.nl.ibm.com)
|
Ensure that at the bottom of the page you see Using Team Java Launcher.
|
| Click Debug.
|
Figure 24-21 Debug configuration for a Java Application
Note that the Team Java Launcher starts the JVM to debug with the following parameters:
-agentlib:jdwp=transport=dt_socket,suspend=y,server=y,address=hostna
me:debugPort -Dfile.encoding=<codepage> -classpath <path>
<MainClass>
You cannot use the Eclipse JDT Launcher for this purpose because it starts the JVM to debug without the server=y parameter.
Observe the Debug perspective (Figure | 4-22). The Debug view should show line referring to the virtual machine decorated with the following text:
[Team] VM [hostname:debugPort]
Figure 24-22 Team Debugging
To transfer the debug session to Patrick, Lara performs these actions:
[Team] VM [hostname:debugPort]
| Select Transfer to User.
|
| Enter the user name or a space followed by the last name to find Patrick.
|
| A dialog shows the attempt to transfer the debug session.
|
Note: The presence of firewalls between the Team Concert Server and Application Developer might prevent this functionality from working. A symptom of such situation would be a message stating:
Unable to add debug session to repository
Reason: Cannot connect to IP_address:debugPort
The IP address and port in the error message are those of the JVM to be debugged (typically on the Team Concert Client). The port is randomly chosen by the Team Launcher, which means that you cannot easily open this port on the firewall. One way of fixing the value of the debug port is to start the Java program in debug server mode instead of using the Team Launcher. Note, however, that it is currently not possible to fix the value of the port used by the Team Debug Service on the Team Concert Server. This is considered an enhancement for a future release.
To launch the Java program in debug server mode:
| Create a new Java launch configuration, and add this in the VM argument:
|
-agentlib:jdwp=transport=dt_socket,suspend=y,server=y,address=hos
tname:debugPort
Note that the hostname used must be recognizable by the Jazz server (do not specify localhost, use the full hostname or IP address).
| Launch this session in Run mode.
|
| Create a Remote Java Application debug configuration and connect to this running JVM for debug.
|
| After being connected, add the debug session to the Jazz server.
|
|
In his workspace, Patrick sees a dialog with the title Incoming Debug Session (Figure | 4-23):
|
|
| Select Import Breakpoints.
|
Figure 24-23 Invitation to accept an incoming debug session from another user
Lara's debug session is suspended at the same line where she left it and Patrick can step into the application from the point where Lara transferred it.
If Patrick has imported the breakpoints, they will be grouped in a Working Set named after Lara's user on the Team Concert Server. The debug output and input streams will be directed to the console of the user that receives the debug session.
Patrick can decide to transfer the session back to Lara at some later stage in the execution. Alternatively, Lara can also request the session back by doing the following steps:
| In the Team Artifacts view, expand the Debug node under the Project Area.
|
| Expand Search Team Debug Session Æ Started by Me.
|
| Identify the session started by Lara and currently being debugged by Patrick.
|
| Right-click the session, and select Debug.
|
| Patrick receives a notification that the debug session is requested by Lara.
|
| When Patrick accepts, Lara will be asked if she wants to import Patrick breakpoints.
|
| A new debug session appears in Lara's Debug view.
|