Start and use the Eclipse-based debugger
To debug your application, first create a Java project or a project with a Java nature in the Eclipse workbench. You must then import the application you want to debug into the project. The steps below provide an example of the steps to follow on a Windows workstation using the WebSphere Application Server Default Application example.
There are two debugging styles available. Step-by-step mode prompts you whenever the server calls a method on a Web object. A dialog allows you to either step into the method or skip it. In the dialog, you can also turn off step-by-step mode. Alternatively, if you know which part of your program you want to debug, you can add breakpoints to this code and run until one of the breakpoints is encountered. Note that breakpoints work with both styles of debugging - step-by-step mode just allows you to see which Web objects are being called without having to set up breakpoints ahead of time.
You do not have to import all of your application into the project. If you do not import all of your application into the project, some of the source may not compile. You can still debug the project and most features of the debugger work including breakpoints, stepping and viewing/modifying variables. However, the inspect and display features in the source view doesn't work if the source has build errors. The inspect and display features allow you to select an expression in the source view and evaluate it. You must import any source that you want to set breakpoints in.
- Map a drive to the iSeries server as follows:
- Right-click Start, and click Explore to open Windows Explorer on your Windows PC.
- Select the Tools --> Map Network Drive... menu item.
- Select a letter of a free drive (such as the I:\ drive).
- In the folder field, enter the name of your iSeries server and file share:
\\MYISERIES\rootwhere MYISERIES is the name of your Series server, and root is the name of the file share you want to use. Note that the file share must allow access to /QIBM.Click Finish.
Start the Application Server Toolkit.
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 button and go to the following directory on the drive you mapped above: QIBM\UserData\WebAS5\Base\instance\installedApps\ node\DefaultApplication.ear\DefaultWebApplication.war where instance is the name of the instance running the application and node is the name of the node for the instance.
Select the checkbox next to DefaultWebApplication.war in the left side of theImport dialog and then click Finish. This does not import the JSPs and Java source for the examples into your project.
- Add any JAR files needed to compile 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 button to add the following JAR files:
- \QIBM\UserData\WebAS5\Base\instance\installedApps\node\ DefaultApplication.ear\Increment.jar. After you have added this JAR file, select it and use the Attach Source button to attach Increment_src.jar as the source.
- /QIBM/ProdData/WebAS5/Base\lib\j2ee.jar
- /QIBM/ProdData/WebAS5/Base\lib\pagelist.jar
- /QIBM/ProdData/WebAS5/Base\\lib\webcontainer.jar
Click OK when you have added all of the JARs.
(Optional) Set some breakpoints in the source at this time if you like, however, it is not necessary as step-by-step mode prompts 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 WAS in debug mode and make note of the JVM debug port.
The default value of the JVM debug port is 7777. See Enable your code and application server for debug for more information.After 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 button and then select WebSphere Application Server Debug from the list of launch configurations. Click the New button 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 the debugging, launch the Application Server Toolkit, select Help --> Help Contents and choose the Debugger Guide entry. To learn about known limitations and problems that are associated with the Application Server Toolkit, see the Application Server Toolkit release notes.