Debugging WAS applications
In order to debug your application, use your application development tool (such as WebSphere Studio Application Developer) to create a Java project or a project with a Java nature. You must then import the program that you want to debug into the project. By following the steps below, you can import the WAS examples into a Java project.
There are two debugging styles available...
- Step-by-step debugging mode prompts you whenever the server calls a method on a Web object. A dialog lets you step into the method or skip it. In the dialog, you can turn off step-by-step mode when you are finished using it.
- Breakpoints debugging mode lets you debug specific parts of programs. Add breakpoints to the part of the code that debug and run the program until one of the breakpoints is encountered.
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 need not import an entire program into your project. However, if you do not import all of your program into the project, some of the source might not compile. You can still debug the project. Most features of the debugger work, including breakpoints, stepping, and viewing 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.
- Create a Java Project by opening the New Project dialog.
- Select Java from the left side of the dialog and Java Project in the right side of the dialog.
- Click Next and then specify a name for the project (such as WASExamples).
- Press Finish to create the project.
- Select the new project, choose File > Import > File System, then Next to open the import file system dialog.
- Select the directory Browse pushbutton and go to the following directory: $WAS_INSTALL\installedApps\node \DefaultApplication.ear\DefaultWebApplication.war.
- Select the checkbox next to DefaultWebApplication.war in the left side of the Import dialog and then click Finish.This will import the JSP files and Java source for the examples into your project.
- Add any JAR files needed to build to the Java Build Path. To do this, select Properties from the right-click menu. Choose the Java Build Path node and then select the Libraries tab. Use the Add External JARs pushbutton to add the following JAR files...
Once you have added this JAR file, select it and use the Attach Source pushbutton to attach Increment.jar as the source - Increment.jar contains both the source and class files.
Click OK when you have added all of the JARs.
- Set some breakpoints in the source at this time if you 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.
- To start debugging, you need to start the WebSphere Application Server in debug mode and make note of the JVM debug port.The default value of the JVM debug port is 7777.
- Once the server is started, switch to the debug perspective by selecting Window > Open Perspective > Debug. You 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.
- Select the workbench toolbar Debug pushbutton and then select WebSphere Application Server Debug from the list of launch configurations. Click the New pushbutton to create a new configuration.
- Give your configuration a name and select the project to debug (your new WASExamples project). Change the port number if you did not start the server on the default port (7777).
- Click Debug to start debugging.
- Load one of the examples in your browser (for example, http://localhost:9080/hitcount).
To learn more about debugging, launch the Application Server Toolkit, select Help > Help Contents and choose the Debugger Guide bookshelf entry. To learn about known limitations and problems that are associated with the Application Server Toolkit, see the Application Server Toolkit release notes. For current information available from IBM Support on known problems and their resolution, see IBM Support page.
IBM Support has documents that can save you time gathering information needed to resolve this problem. Before opening a PMR, see IBM Support page.
See AlsoDebugging with the Application Server Toolkit