What is Remote Debugging?

Remote debugging allows the debugger tool to run in a separate process or machine from the process being debugged. Java Platform Debugger Architecture (JPDA) allows for remote debugging. In this mode, a JVM acts as a server to a debugger tool. The debugger tool is written using the Java Debug Interface (JDI) API. The communication protocol between the debugger and the JVM is standardized using the Java Wire Protocol (JWP). A JVM must support various debugging services as specified by the JVM Debug Interface (JVMDI). This allows a generic debugger tool to debug JVM processes from different vendors.

WSAD can act as a fully JPDA compliant debugger tool. In other words, it is coded using the JDI API to talk to any JVM that supports JVMDI.

Why Use Remote Debugging?

Remote debugging comes handy in a few scenarios.

  • A problem appears in the production platform only.
  • You are extending a large third party application. It is not possible to import all the code in WSAD and have a proper J2EE project structure created. In this case, you can use WSAD to build your custom code and export it as a JAR file and deploy it inside the third party application running in a standalone WebSphere installation.

The Basic Steps

Remote debugging in WSAD requires a few simple steps.

  1. Configure the remote application server. Specify the TCP/IP port number used by the debugging component of the JVM. Enable the server to start in debug mode.
  2. Configure WSAD to perform remote debugging. To do this, create a test server of type Remote Server Attach. In this server configuration enter the host name and port number of the remote application server process.

Configuring WebSphere Application Server

Using a browser, open the administration screen of the remote WebSphere system. Expand the Servers node and click on Application Servers. Click on the appropriate server’s name to open the application server’s properties screen. Click on the Debugging Service link. Switch on the Startup check box. Note that, by default, the service uses port 7777 to receive a connection from the debugger client (WSAD). You can change it if you want. Click Apply and then save the configuration.

Enabling the debugging service also configures the server to start in debug mode. You don’t need to set that separately from the Process Definition > Java Virtual Machine page.

Stop the application server if it is running. Start it. This time the server will start in debug mode and will take a little longer to start.

Configure WSAD

Make sure that the Enterprise Application project that you want to debug is loaded into the workspace. Ofcourse, the application must also have been deployed in the remote server. Ensure that the version of the code deployed is same as what is in WSAD.

WSAD uses JPDA for remote debugging any Java application. The regular remote debugging process involves creating a debug launch configuration. For WebSphere applications, the process is much simplified by the use of a server configuration of type remote server attach.

Create a new server configuration of type WebSphere version 5.1->Server Attach. A server configuration of this type is just a place holder for information such as the remote server’s IP address and the port number the debugging service listens on.

Click on Next. Then enter the host name of the remote machine.

Click on Next. Now enter the port being used by the debugging service in the application server. The default (7777) matches the default in the application server settings.

APPLICATIONS REMOTELY TUTORIAL

Finally, click on Finish to create the remote server configuration.

Add the enterprise application project to the server (rght click on the server in the Servers view and select Add remove projects). This merely sets up the source code search path for remote debugging. Sysem does not actually deploy the application to the remote server.

Start the server in debug mode (right click on the server in the Servers view and select Debug). This does not really start the server. WSAD simply connects to the debugging service running in the remote server.

Put break points in your code. By default “Step-by-step” debugging is enabled. This means, WSAD automatically puts hidden breakpoints at the start of every Servlet and JSP. You may not necessarily want that. To disable this mode, open the Preferences dialog and select the WAS Debug node and disable step by step debugging.

Start testing the software. WSAD should halt execution at the break points and you should be able to carry out normal debugging.

Ending a Debug Session

At the end of the debug session, right click on the server in the Servers view and select Disconnect.

You probably want to restart the application server in non-debug mode. To do this, disable the debug service for the application server and restart the server. Once again, there is no need to separately disable the debug mode for the JVM. Disabling automatic startup of the debug service will do that for you.