Tracing and debugging a Java client
and C++ Business Object (Windows NT/2000)
Objective
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:

Description
In this exercise, you will complete these steps:
- Start Object Level Trace.
- Run your application to produce a trace.
- Set a breakpoint on the business object.
- Rerun your application for tracing and debugging.
- Debug the server method.
- Step from server to client code for tracing and debugging.
- Disable the breakpoint.
- Run the application to completion.
Sample instructions
Follow these steps to perform the tracing and debugging for this scenario:
- 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.
- Run your application to produce a trace.
- From a command prompt, change to the directory where you compiled the Java client
version of the Policy sample
- 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.)
- A trace is created, showing the calls from your client to the Policy and PolicyHome
objects on the server.
- Set a breakpoint on the business object.
- 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:

- Right-click and select Add to method to breakpoint list.
- Rerun your application for tracing and debugging.
- Change to a debugging mode.
- In the Viewer window, on the Client Controller page select Trace and debug
for Default settings and then click Apply.
- In the OLT Viewer, from the Options menu, deselect Step-by-step
Debugging Mode.
- From a command prompt, change to the directory where you compiled the Java client
version of the Policy sample.
- 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.
- Debug server method.
- The program halts at your breakpoint and the debugger prompts for the source file
location:

Click Browse to find the file, as follows:

Click Open and then OK to open the source file
- The debugger opens and steps into the getpremium method on the server:

- Step from server to client code for tracing and debugging.
- 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:

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

- 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.
- 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.

Component Broker Object Level Trace examples
OLT Overview