C H A P T E R  5

Validating Your Sun ONE Studio 4 Installation

This chapter contains information on how to validate your installation of the Sun ONE Studio 4, Enterprise Edition for Java. Instructions are provided to help you through the creation of a simple HelloWorld web application using the J2EE Reference Implementation 1.3.1.



Note - The following instructions assume you have already installed the J2EE Reference Implementation 1.3.1 during the IDE installation.




Starting the Default J2EE Reference Implementation Instance

The J2EE Reference Implementation server is configured automatically when you install the J2EE Reference Implementation 1.3.1 during the Sun ONE Studio 4 IDE installation. An instance of the J2EE Reference Implementation is added to the IDE's server registry. This instance is also set to be the default application server after the IDE installation.

If the J2EE Reference Implementation 1.3.1 is not active when you deploy or execute an application, it automatically starts.

The following instructions explain how to start and verify the default J2EE Reference Implementation server instance:

1. Start the Sun ONE Studio 4 IDE.



Note - See for more information on s1studio-ide-options.



2. Verify that the RI Home property is set correctly.

a. In the Explorer window of the IDE, click the Runtime tab and expand the nodes for Server Registry and Installed Servers.

b. Right-click J2EE Reference Implementation 1.3.1 and choose Properties from the contextual menu. (Alternately, you can select the J2EE Reference Implementation 1.3.1 node and look below the Explorer at the Stationary Property window.)

The property sheet for J2EE Reference Implementation appears.

c. Verify that the RI Home property already has a value of s1studio-user-directory/j2sdkee1.3.1.

If it does not, set the value by selecting the RI Home property and typing the correct value. If you must manually enter a value, be sure you have write access to the RI installation directory that you enter.

3. Start the J2EE Reference Implementation 1.3.1 instance.

a. Expand the Server Registry and Installed Server nodes from the Runtime tab of the Explorer window.

All the application servers that have already been installed are listed under the Installed Servers node.

b. Expand the J2EE Reference Implementation 1.3.1 node.

You can see the RI instances that have already been added to the Server Registry.

c. Right-click RI Instance 1 and choose Start Server from the contextual menu.

The corresponding messages appear in the Output window. For example, in a Microsoft Windows system, you see the following:

J2EE server listen Port: = 1050Redirecting the output and error streams to the following files:s1studio-user-directory\j2sdkee1.3.1\logs\myhost\j2ee\j2ee\system.outs1studio-user-directory\j2sdkee1.3.1\logs\myhost\j2ee\j2ee\system.errJ2EE server startup complete.

4. Verify the server instance status in a web browser using http://localhost:8000 for the URL.

If you have correctly integrated your server, you see the J2EE 1.3.1 Default Home Page.



Note - If you receive an error message when verifying the server instance status, refer to Chapter 10 for some troubleshooting hints. If you need to modify the default port settings assigned to the J2EE Reference Implementation 1.3.1, e.g. in a multiuser environment, refer to Appendix B for information.




Creating a HelloWorld J2EE Application

The following steps guide you in creating a simple test application using the J2EE Reference Implementation 1.3.1 that was installed with the IDE.



Note - The following instructions assume you have already started the default J2EE Reference Implementation instance. See Starting the Default J2EE Reference Implementation Instance for more information.



1. Create a new directory called verificationApp.

2. Start the Sun ONE Studio 4 IDE, if you have not already done so.

  • On Microsoft Windows systems, choose Programs right arrow Sun Microsystems right arrow Sun ONE Studio 4 EE right arrow Sun ONE Studio from the Start menu, or start a command window and type the following:
  • C:\>cd s1studio-install-diectory\bin
    
    C:\s1studio-install-directory\bin>runidew.exe
    

  • In a Solaris or Linux environment, type the following command at the command line:
  • $ cd s1studio-install-directory/bin
    
    $ runide.sh [s1studio-ide-options]
    



Note - See for more information on s1studio-ide-options.



  •  

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

The New wizard appears.

a. Select Local Directory and click Next.

b. Select the newly created directory, verificationApp, and click Finish.

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

4. In the Filesystems tabbed pane of the Explorer window, create a new Java package named hello by right-clicking the verificationApp node and choosing New right arrow Java package.

The New wizard for a Java package appears.

5. 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.

6. In the Explorer window, right-click the hello node and choose New right arrow J2EE right arrow Session EJB to create a new session bean named helloTest.

The New wizard for a session bean appears.

7. Specify the bean name as helloTest, use all the default settings on the New wizard, and click Finish.

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

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

The Add New Business Method dialog box appears.

9. In the Add New Business Method dialog box, name the method sayHello.

a. Set the return type by selecting java.lang.String from the combo box.

b. Click OK.

10. 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. Right-click sayHello(), and choose Open.

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

c. In the Source Editor, add one line, so the method looks like this:

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

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

If no compilation errors are encountered, the Output window displays the message Finished helloTestBean.

12. From the Filesystems tabbed pane of the Explorer window, create a new EJB Test application by right-clicking the helloTest(EJB) node and choosing Create New EJB Test Application.

The Create a New EJB Test Application dialog box appears.

13. 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.

14. 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://localhost:8000/helloTest_TestApp/dispatch.jsp page is displayed, the J2EE Reference Implementation server is working correctly.

You have now verified that your installation of the IDE and the J2EE Reference Implementation is working properly. At this point, you can skip the steps remaining in this chapter or continue to run the session bean's method.

15. Run the session bean's method by clicking the Invoke button next to hello.helloTest create in the http://localhost:8000/helloTest_TestApp/dispatch.jsp page in your web browser.

The correct button is the first Invoke button on the page, under Invoke Methods in the hello.helloTestHome section.

a. In the EJB Navigation section of the next page, click hello.helloTest[7].

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

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

The Results of the Last Method Invocation section displays the following:

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

You have completed running the session bean's method.