Tracing and debugging a Java client and C++ Business Object (Windows NT/2000)

Objective
The following information applies to Windows.The objective of this sample is to trace and debug a distributed application in which the client code is written in Java and the business object is written in C++. Both are installed on Windows NT/2000.

Before You Begin
You must complete the steps to compile and install the Policy sample for Windows NT/2000, including the Java client application (as explained in the Preparing for the OLT tutorials).

For this exercise, a single Windows NT/2000 workstation is running OLT, the debugger, and your client and server applications, as follows:

olt1a.gif (2989 bytes)

Description
In this exercise, you will complete these steps:

  1. Start Object Level Trace.
  2. Run your application to produce a trace.
  3. Set a breakpoint on the business object.
  4. Rerun your application for tracing and debugging.
  5. Debug the server method.
  6. Step from server to client code for tracing and debugging.
  7. Disable the breakpoint.
  8. Run the application to completion.

Sample instructions
Follow these steps to perform the tracing and debugging for this scenario:

  1. To start Object Level Trace on your Windows NT/2000 system, type olt in a command window . OLT starts. Make sure that Trace only has been selected for the Execution mode in the client controller page for Default settings in the OLT viewer window. If you have to change this setting, click Apply.
  2. Run your application to produce a trace.
    1. From a command prompt, change to the directory where you compiled the Java client version of the Policy sample
    2. Enter the following command:
      java
      -Dcom.ibm.CORBA.EnableApplicationOLT=true
      -Dcom.ibm.CORBA.OLTApplicationHost=<OLT_Server_Host>
      -Dcom.ibm.CORBA.OLTApplicationPort=<OLT_Server_Port>
      -DOLTClient=true
      -classpath "d:\cbroker\samples\InstallVerification\ProgrammingModel\
      BusinessObjects\Policy\Working\NT\TRACE_DEBUG\jcb\jcbPolicyC.jar;
      d:%SOMCBASE%\lib\somojor.zip;D:%SOMCBASE%\lib\dertrjrt.jar;%CLASSPATH%" 
      PolicyApp

      where:
      <OLT_Server_Host> is the fully qualified name or TCP/IP address of the machine running your OLT server
      <OLT_Server_Port> is the port where the OLT server listens for connecting OLT clients. (2102 is the default.)

    3. A trace is created, showing the calls from your client to the Policy and PolicyHome objects on the server.
  3. Set a breakpoint on the business object.
    1. Select the event that represents the getpremium method. To find the event, pass the mouse over the events in the OLT viewer and look in the Current line at the bottom of the window for the getpremium method call. Here is an example of the Selected and Current lines:

      npnoflyo.gif (15554 bytes)

    2. Right-click and select Add to method to breakpoint list.
  4. Rerun your application for tracing and debugging.
    1. Change to a debugging mode.
      1. In the Viewer window, on the Client Controller page select Trace and debug for Default settings and then click Apply.
      2. In the OLT Viewer, from the Options menu, deselect Step-by-step Debugging Mode.
    2. From a command prompt, change to the directory where you compiled the Java client version of the Policy sample.
    3. Enter the following command:

      JDK 1.2.2+JPDA

      java -Xdebug -Xnoagent 
      -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=<JVM_port> 
      -Djava.compiler=NONE 
      -Xbootclasspath/a:"<WebSphere_jdk>\lib\tools.jar;<WebSphere>\lib\derdbpw.jar"
      -Denv.class.path=%DEBUG_CP%
      -Dcom.ibm.debug.jdwpport=<JVM_port> 
      -Dcom.ibm.CORBA.requestTimeout=0
      -Dcom.ibm.CORBA.EnableApplicationOLT=true
      -Dcom.ibm.CORBA.OLTApplicationHost=<OLT_Server_Host>
      -Dcom.ibm.CORBA.OLTApplicationPort=<OLT_Server_Port>
      -Dcom.ibm.CORBA.BootstrapPort=900
      -DOLTClient=true
      -classpath "d:\cbroker\samples\InstallVerification\ProgrammingModel\
      BusinessObjects\Policy\Working\NT\TRACE_DEBUG\jcb\jcbPolicyC.jar;
      d:\cbroker\lib\somojor.zip;D:\WebSphere\AppServer\lib\dertrjrt.jar;%CLASSPATH%" 
      -Xbootclasspath/a:"%JAVA_HOME%\lib\tools.jar;D:\WebSphere\AppServer\lib\derdbpw.jar" 
      PolicyApp

      Where:

      • <WebSphere_jdk> is the where the WebSphere JDK is installed, for example, c:\WebSphere\AppServer\java.
      • <WebSphere> is the where the WebSphere AppServer is installed.
      • %DEBUG_CP% has the location of the Java source code.
      • <OLT_Server_Host> is the fully qualified name or TCP/IP address of the machine running your OLT server
      • <OLT_Server_Port> is the port where the OLT server listens for connecting OLT clients. The default is 2102.
      • <JVM_port> is the port for the JVM. It is a free port number.

      If you are using other JDK levels, see JDK 1.1.x and JDK 1.3.x for the appropriate java command.

  5. Debug server method.
    1. The program halts at your breakpoint and the debugger prompts for the source file location:

      filename.gif (3743 bytes)

      Click Browse to find the file, as follows:

      filename2.gif (7984 bytes)

      Click Open and then OK to open the source file

    2. The debugger opens and steps into the getpremium method on the server:

      npnoja2a.gif (4573 bytes)

  6. Step from server to client code for tracing and debugging.
    1. Click Step over once. This creates another debugger page for the client, and shows you the client stub code, at the step immediately past the call to the getpremium method:

      npnoja3a.gif (4471 bytes)

    2. On the client debugger toolbar, click Step return once. The following client code is shown:

      npnoja4a.gif (3420 bytes)

  7. Disable the breakpoint and run the application to completion.
    In the OLT window, select Breakpoints > List method breakpoints. Select the getpremium method and click Disable and then Cancel to close the window.
  8. In the Debugger window, click Run. The application runs to completion.

Important Note:
While running your application, do not close the debugger window you are using to debug server code. Doing so shuts down the application server (this is a Windows NT/2000 limitation). When you finish debugging, stop your application server using System Manager, then close the OLT window.

ngrelr.gif (548 bytes)
Component Broker Object Level Trace examples
OLT Overview