+

Search Tips   |   Advanced Search

Debug applications


To debug the application, use a development environment like the IBM Rational Application Developer for WebSphere to create a Java project. You must then import the program that you want to debug into the project.

By following the steps below, we can import the WAS examples into a Java project. Two debugging styles are available:

Breakpoints actually work with both styles of debugging. Step-by-step mode just lets you see which Web objects are being called without having to set up breakpoints ahead of time.

You do not need to import an entire program into the project. However, if we do not import all of the program into the project, some of the source might not compile. We can still debug the project. Most features of the debugger work, including breakpoints, stepping, and modifying variables. You must import any source that you want to set breakpoints in.

The inspect and display features in the source view do not work if the source has build errors. These features let you select an expression in the source view and evaluate it.

 

  1. Create a Java Project by opening the New Project dialog.

  2. Select Java from the left side of the dialog and Java Project in the right side of the dialog.

  3. Click Next and specify a name for the project, for example, WASExamples.

  4. Click Finish to create the project.

  5. Select the new project, choose File > Import > File System, then Next to open the import file system dialog.

  6. Browse the directory for files.

    Go to...

    $WP_PROFILE/installedApps/node_name/DefaultApplication.ear/DefaultWebApplication.war

  7. Select DefaultWebApplication.war in the left side of the Import dialog and then click Finish. This imports the Java Server Pages files and Java source for the examples into the project.

  8. Add any JAR files needed to build to the Java Build Path. Select Properties from the right-click menu. Choose the Java Build Path node and then select the Libraries tab. Click Add External JARs to add the following JAR files:

    • $WP_PROFILE/installedApps/node_name/DefaultApplication.ear/Increment.jar.

      When we have added this JAR file, select it and use the Attach Source function to attach the Increment.jar file because it contains both the source and class files.

    • APP_ROOT/lib/j2ee.jar
    • APP_ROOT/plugins/com.ibm.ws.runtime.jar
    • APP_ROOT/plugins/com.ibm.ws.webcontainer.jar

    Click OK when we have added all of the JARs.

  9. We can set some breakpoints in the source at this time if we like, however, it is not necessary as step-by-step mode will prompt you whenever the server calls a method on a Web object. Step-by-step mode is explained in more detail below.

  10. To start debugging, we need to start the WAS in debug mode and make note of the JVM debug port. The default value of the JVM debug port is 7777.

  11. When the server is started, switch to the debug perspective by selecting Window > Open Perspective > Debug. We can also enable the debug launch in the Java Perspective by choosing Window > Customize Perspective and selecting the Debug and Launch checkboxes in the Other category.

  12. Select the workbench toolbar Debug pushbutton and then select WAS Debug from the list of launch configurations. Click the New pushbutton to create a new configuration.

  13. Give the configuration a name and select the project to debug (your new WASExamples project). Change the port number if we did not start the server on the default port (7777).

  14. Click Debug to start debugging.

  15. Load one of the examples in the browser. For example: http://your.server.name:9082/hitcount

 

Next steps

To learn more about debugging, launch the The IBM Rational Application Developer for WebSphere, select Help > Help Contents and choose the Debugger Guide bookshelf entry. To learn about known limitations and problems that are associated with the IBM Rational Application Developer for WebSphere, see the IBM Rational Application Developer for WebSphere release notes. For current information available from IBM Support on known problems and their resolution, see the IBM Support page.

IBM Support has documents that can save you time gathering information needed to resolve this problem. Before opening a PMR, see the Must gather documents page for information to gather to send to IBM Support.


Debugging components in the IBM Rational Application Developer for WebSphere