Task 3: Deploy and test your application
In this section, you will start the WebSphere Application Server, add your project to the application server runtime environment, and test your application using the simple JSP client that was created as part of the J2C Java Bean wizard.
Select the Servers view within the J2EE perspective.
- Using the Servers view, select the WebSphere Application Server v6.1 and click the green forward arrow icon to start the server, as shown in Figure 37. It will take a few moments for the application server to start:
Figure 37. Starting the WebSphere Application Server
After the Console displays the "Server server1 open for e-business" message, click the Servers view and check the Status indicator.
- When the WebSphere Application Server is started, the Servers view will display Started in the Status field, and Synchronized in the State field, as shown in Figure 38:
Figure 38. Status and State of the WebSphere Application Server
- You now must add your project to the started application server. Using the Servers view, right-click WebSphere Application Server v6.1 and select Add and Remove Projects, as shown in Figure 39.
Figure 39. Adding your project to the started application server
- From the Add and Remove Projects page, select J2CPhoneBookEAR and click Add > to add your project to the Configured Projects, as shown in Figure 40.
Figure 40. Adding your project to configured projects
- Click Finish to add your project to application server. The WebSphere Application Server will publish the application, as shown in Figure 41:
Figure 41. Publishing the application
- WebSphere Application Server then returns to a Synchronized state, as shown in Figure 42:
Figure 42. Returning to synchronized state after publishing the application
- If not switched automatically, switch to the Console view and verify that the application has started successfully, as shown in Figure 43.
Figure 43. Console view
In this section you will test the simple JSP client that was created as part of the J2C Java Bean wizard.
Select the generated TestClient.JSP file that is located in the myJSPs folder. Recall that this is the folder you created to store the simple JSP test client. If the TestClient.JSP file is not visible, navigate to the J2CPhoneBook > WebContent> myJSPs folder in the Project Explorer.
- With the TestClient.jsp selected, Right-click and select Run As > Run On Server, as shown in Figure 44.
Figure 44. Running the TestClient.jsp
- Choose the started WebSphere Application Server v6.1 and click Finish to run the TestClient.jsp, as shown in Figure 45:
Figure 45. Choosing the server to run the JSP
- The Web Services Test Client will launch the TestClient.jsp. Notice that there are three separate panes (Java Methods, Input parameters, and Results) within the TestClient.jsp, as shown in Figure 46:
Figure 46. The Web Services Test Client view
Double-click the Web Services Test Client title to maximize the window within the workbench, and then click the
runPhoneBookmethod to test.
Enter the following values to test the J2C bean, as shown in Figure 47:
Make sure not to enter any spaces before or after any of the input fields.
- Click Invoke to run the application.
Figure 47. Testing TestClient.jsp in the Web Services Test Client
- Resize the result area to check your results, as shown in Figure 48:
Figure 48. Resizing the result area
You should see something similar to the results shown in Figure 49.
Figure 49. Results from the testing
Select Windows > Reset perspective and OK.
- Using the Servers perspective, click the red square icon to stop the WebSphere Application Server, as shown in Figure 50:
Figure 50. Stopping the WebSphere Application Server
- Close all open editor windows (pressing Ctrl+Shift+F4 should accomplish this).
You have completed the IMS J2C tutorial. If you have extra time, you can do a bit more. How about taking the generated J2C bean and wrapping that as a Web service? This feature extends the usage of your J2C bean past simple Web clients and offers the transaction as a Web service.