C H A P T E R  7

Validating Your IDE Installation

This chapter describes how to validate your installation of the Sun ONE Studio IDE by showing you how to create a simple web application using Sun ONE Application Server 7. This chapter covers:



Note - The following instructions assume that you installed the IDE and the Sun ONE Application Server 7 and have configured your default application server. See Chapter 6 for information about configuring the application server.




Creating a J2EE Platform Application

The following steps show you how to create a simple test application for the Javatrademark 2 Platform, Enterprise Edition Specification (J2EE platform) using Sun ONE Application Server 7.

1. Create a new directory called helloApp.

2. Start the IDE, if you have not already done so and confirm that Sun ONE Application Server 7 is your default application server.

See Chapter 6 for more information.

3. Mount the helloApp directory in the IDE by choosing File right arrow Mount Filesystems from the main window.

The New wizard appears.

a. Select Local Directory and click Next.

b. Select the helloApp directory, and click Finish.

A helloApp node appears in the Filesystems tabbed pane of the Explorer window.

4. Create a new Java package named hello.

a. Right-click the helloApp node and choose New right arrow Java package.

The New wizard for a Java package appears.

b. In the New wizard, type the name hello for the new Java package and click Finish.

A new node for the hello package appears on the Filesystems tabbed pane of the Explorer window.

5. Create a new session bean named helloTest by doing the following:

a. In the Explorer window, right-click the hello node and choose New right arrow All Templates.

The New Wizard appears.

b. Expand the J2EE node, choose Session EJB, and click Next.

The New Wizard for a Session EJB appears.

c. Type helloTest in the EJB Name text field, keep all the default settings on the New wizard, and click Finish.

The helloTest(EJB) node appears in the Filesystems tabbed pane of the Explorer window. Nodes for helloTest, helloTestBean, and helloTestHome also appear.

6. Add a business method by right-clicking the helloTest(EJB) node and choosing Add Business Method.

The Add New Business Method dialog box appears.

7. Type sayHello as the method name.

8. Set the return type by selecting java.lang.String from the combo box and click OK.

9. Edit the sayHello method using the Source Editor:

a. In the Explorer window, expand the helloTest(EJB) node and expand the Business Methods node.

b. Select sayHello(), right-click, and choose Open.

The Source Editor opens and displays the contents of the helloTestBean method.

c. Add one line so that the helloTestBean method looks like this:

public java.lang.String sayHello() {
return "Hello there, Studio!";
}

10. Choose Build right arrow Compile from the main IDE window or press F9 to compile the sayHello method.

If no compilation errors are found, the Output Window(Compiler) displays the message Finished helloTestBean.

11. From the Filesystems tabbed pane of the Explorer window, create a new EJB Test application by doing the following:

a. Right-click the helloTest(EJB) node and choose Create New EJB Test Application.

The Create a New EJB Test Application dialog box appears.

b. Accept all the default values by clicking OK.

An EJB module called helloTest_EJBModule, a web module named helloTest_WebModule, and an application named helloTest_TestApp are created and automatically mounted in the IDE.

12. In the Filesystems tab of the Explorer window, right-click the helloTest_TestApp node and choose Execute.

A progress monitor is displayed and the IDE switches to the Running tab. The helloTest_TestApp is deployed and your web browser appears with the URL displayed as http://localhost:8000/helloTest_TestApp/dispatch.jsp.

If the browser is not displayed automatically, open it manually and type http://localhost:8000/helloTest_TestApp for the URL.



Note - Ensure that your web browser is configured to not use proxy servers for domains beginning with localhost.



If the http://admin-server-host:admin-server-portnumber/helloTest_TestApp/dispatch.jsp page is displayed, the application server is working correctly.

You have now verified that your installation of the IDE is working properly with the Sun ONE Application Server 7.

At this point, you can skip the steps remaining in this chapter or continue to run the session bean's method.

13. (Optional) Run the session bean's method.

a. On the http://admin-server-host:admin-server-portnumber/helloTest_TestApp/dispatch.jsp page in your web browser, click the Invoke button next to hello.helloTest create.

The correct button is the first Invoke button on the page, under the heading Invoke Methods on the hello.helloTestHome. The browser page is refreshed.

b. In the EJB Navigation section of the browser page, click hello.helloTest[7].

The number 7 might be some other number in your web browser.

c. Click Invoke next to java.lang.String sayHello.

The page refreshes and section, The Results of the Last Method Invocation displays the following:

Hello there, Studio!
 
Method Invoked: sayHello()
Parameters:
none

You have completed running the session bean's method.