C H A P T E R 1 |
Getting Started |
This chapter describes what you must do before starting the Sun Java Studio Enterprise 6 J2EE Application tutorial. The topics covered in this chapter are:
Note - There are several references in this book to the DiningGuide application files. These files include a completed version of the tutorial application, a readme file describing how to run the completed application, and SQL script files for creating the required database tables. These files are compressed into a zip file you can download from the Java Studio Enterprise Developer Resources portal at http://developers.sun.com/prodtech/javatools/jsenterprise/learning/tutorials/index.html. |
The following items are required to create and run the tutorial.
The Java Studio Enterprise installer installs both products unless it detects a supported version of the Sun Java System Application Server already installed.
You can obtain the Java Studio Enterprise software from:
The Java Studio Enterprise installer installs this version of the J2SE if it is not already on your system.
This tutorial uses the PointBase database. PointBase is installed with the Java Studio Enterprise software, in the subdirectory that contains the Sun Java System Application Server software. If your IDE and application server were installed separately, your application server may not include PointBase software. If it does not, you must download and install PointBase software from http://www.pointbase.com/home.shtml. Instructions for connecting to an external PointBase installation are found in the Sun Java Studio Enterprise 6 Installation Guide.
The tutorial database tables are included in the default PointBase database installed in your user directory. The tables are described in Tutorial Database Table Descriptions. Appendix C describes how to install the tutorial tables in an Oracle database.
You need a web browser to view the tutorial application pages. This can be either Netscape Communicator or Microsoft's Internet Explorer.
General system requirements are described in the release notes available from the Java Studio Enterprise Developer Resources portal's Documentation page at http://developers.sun.com/prodtech/javatools/jsenterprise/reference/docs/index.html.
This section describes how to start the Java Studio Enterprise IDE and Sun Java System Application Server after the software has been installed.
There are several ways to start the Java Studio Enterprise IDE. Only one is described here. For more options, see the Sun Java Studio Enterprise 6 Installation Guide.
Start the Java Studio Enterprise IDE by running the program executable.
The java-studio-install-dir variable stands for the IDE's home directory, which is by default /opt/SUNWjstudio.
The Sun Java Enterprise System installer creates a preconfigured default administrative domain for the Sun Java System Application Server user. By server design, this administrative domain and its associated server belong to the superuser.
On Microsoft Windows machines, it is common for users to have userids with administrative (that is, superuser) privileges. If this is true of your userid, you can start the application server using all default settings, as described in either Starting the Application Server and Admin Server From Outside the IDE (Microsoft Windows Users) or Starting the Default Admin Server for the Default Domain.
On Solaris systems, where standard userids normally do not have root privileges, your administrator can specify during the installation of Java Studio Enterprise that the default admin domain and server instance will belong to a specific non-root (standard) user account. If this is your account, you can start the application server using all default settings, as described in Starting the Default Admin Server for the Default Domain.
In all other cases, your administrator must first create a non-root domain for you before you can start the Application Server. Instructions for creating this non-root domain are provided in the Sun Java Studio Enterprise 6 Installation Guide. Once this non-root domain has been created, use the procedures described in Starting the Admin Server for a Non-Default Domain to create the Application Server's admin and instance nodes in the IDE.
Microsoft Windows users can start both the admin server and the application server instance from the Start menu. This method starts the servers of all domains that exist on the machine. You can do this whether or not the IDE is running.
To start the Application Server:
Choose Start
Programs
Sun Microsystems
Java Studio Enterprise 6 2004Q1
Start Servers
Application Server.
A command window is displayed, listing the servers as they are being started. When all admin servers and all application server instances have been started, the command window disappears. In the IDE, the Server Registry folder in the RunTime tab of the Explorer looks like this:
If you can start the server with this method, go now to Setting the Sun Java System Application Server as the Default Server
Use this section if you are authorized to use the default domain. See the explanation in Starting the Application Server.
To start the default admin server:
1. In the Explorer in the main IDE window, select the Runtime tab.
The Runtime pane of the Explorer displays a number of nodes, including the Server Registry node. This node contains subnodes for all the installed web and application servers, and a node showing which servers are the default servers.
2. Select the Server Registry node.
If this is the first time you have started the admin server, a query window pops up, asking whether you want to start the admin server. This refers to the default domain's admin server.
The IDE starts the default admin server and configures Sun Java System Application Server as the IDE's default application server. It also creates a server instance, server1.
4. Expand the Server Registry node, the Installed Servers node, and the Sun ONE Application Server 7 node.
The Server Registry in the Explorer looks like this:
Now, start the server instance, as described in Starting the Application Server Instance From the IDE.
Use this section if you are a standard user and your administrator has already created a domain for you. See the explanation in Starting the Application Server.
1. In the Explorer in the main IDE window, select the Runtime tab.
The Runtime pane of the Explorer displays a number of nodes, including the Server Registry node. This node contains subnodes for all the installed web and application servers, and a node showing which servers are the default servers.
2. Select the Server Registry node.
If this is the first time you have started the admin server, a query window pops up, asking whether you want to start the admin server. This refers to the default domain's admin server.
If you click OK, this action creates and starts an admin server that you cannot use.
This dismisses the query window and you can now add your admin server.
4. Add your admin server to the IDE.
a. Expand the Server Registry node and the Installed Servers node.
b. Right-click the Sun ONE Application Server 7 node and choose Add Admin Server.
The Add Admin Server dialog box is displayed.
c. Type in your values (see table below) and click OK.
Contact the superuser or administrator who installed the IDE and created your user admin domain to get these values:
userpassword, user password used in the create-domain command |
|
The following error message might display:
e. Click OK to dismiss this error message.
The local admin server is started and your new admin server is added to the IDE. A new admin server node is generated in the Explorer. In the following screen shot, for example, a new admin server's host is localhost and port number is 4850.
5. Create an application server instance.
a. Right-click the new admin server node and choose Create a Server Instance.
The Enter Server Instance Values dialog box is displayed.
b. Type in a name and an available port number.
For example, you could type MyServer and 4855.
Note - On Solaris systems, port numbers below 1024 are reserved. Use a port number above 1023. On all systems, do not use the port number used by the default application server. |
This action starts the admin server, which you can verify by messages in the output window and status bar. The new server instance is created in the IDE.
6. Set the default application and web server by right-clicking the new server instance and choosing Set As Default.
7. Expand the Default Servers node to verify this action.
The default servers for J2EE applications and web tier applications show the new server as the default.
Now start the server instance, as described in the next section.
When you are test deploying applications during development, the IDE starts the application server instance automatically as long as the admin server is running. In this section, start the application server instance manually in order to perform some operations described later in this chapter.
All users start the server instance as follows:
1. Right-click the application server node and choose Status.
Note - If this node is not displayed, select the admin server instance node and choose Refresh. |
The Sun ONE Application Server Instance Status dialog box is displayed, as shown (your instance label may be different).
2. Click the Start Server button.
(If the dialog box has a Stop Server button, the server is already running.)
On Microsoft Windows systems, a command window appears, displaying progress messages.
The server is started when the Server Instance Status window displays Status: Running.
3. Click Close on the instance status dialog box.
Now, proceed to Setting Up Database Connectivity.
If you have started Sun Java System Application Server before, this is how you confirm that it is still the default server, or set it as the default, if it isn't:
1. In the IDE, select the Runtime tab of the Explorer.
2. Expand the Server Registry node and its Default Servers subnode.
If the J2EE Applications node's label is server-instance(server-hostname:server-port-number), as shown, then Sun Java System Application Server is the default application server. Go to the next section. Otherwise, continue with the next step.
3. Find your application server instance under the Installed Servers node, right-click it, and choose Set As Default.
Your server is set as the default server for J2EE and Web Tier applications.
An enterprise application uses the Java Database Connectivity (JDBC) API to interact with a database. Before you can deploy and execute an enterprise application with Sun Java System Application Server, the following required JDBC-related actions must be performed in the application server environment. These include:
Enterprise applications require pooling of database connections so that the business objects in the system can share database access.
A JDBC data source (also called a JDBC resource) lets you make connections to a database with the getConnection() method.
A persistence manager is a component responsible for the persistence of the entity beans installed in the container.
In many cases, all these actions are set for you, providing the values required by the tutorial. If they are not automatically set for you, instructions are provided in Setting JDBC Resources
Exceptions to automatic enabling of the JDBC driver are described in the next section.
The PointBase JDBC driver is installed automatically with the standard installation, where the Java Studio Enterprise IDE and Sun Java System Application Server are installed together.
JDBC resources are set automatically for the default domain. This section describes how to set these resources if they have not been set automatically (on either Microsoft Windows or Solaris systems).
Note - Before starting this procedure, make sure both the admin server and the application server are running (refer to Starting the Software). |
To create the JDBC connection resources for this tutorial:
1. In the Runtime pane of the Explorer, expand the Server Registry and Installed Servers nodes.
2. Locate your application server instance.
It is labeled app-server-name (app-server-host:app-server-port), for example, MyServer (localhost:4855).
3. Right-click the application server instance node and choose Preconfigure PointBase JDBC Resources.
A timer icon (such as an hour glass) appears. When the process is complete, the cursor reverts to its usual icon.
4. Expand the registered resources for JDBC Connection Pools, JDBC Data Sources, and Persistence Managers.
You should see the following nodes under these:
The Explorer for a standard user looks like this:
The Explorer for a Microsoft Windows administrator user looks like this:
Now proceed to the tutorial's database tables.
The DiningGuide tutorial uses two database tables, Restaurant and CustomerReview. These tables are automatically created for you in the PointBase default (sample) database with the standard installation, where Java Studio Enterprise software and Sun Java System Application Server are installed together.
However, if Java Studio Enterprise software and Sun Java System Application Server were not installed together, you must follow the procedures described in Enabling the JDBC Driver. This action not only enables the PointBase JDBC driver, but copies the default sample database to your user directory, which makes these tables available to you.
The database schemas shown in TABLE 1-1 are used in this tutorial. They are created in the PointBase database by the Java Studio Enterprise installer.
Compound primary key with CustomerName; references Restaurant(restaurantName) |
|||
The Restaurant table contains the records shown in TABLE 1-2.
The CustomerReview table contains the records shown in TABLE 1-3.
Now you are ready to start the tutorial application. Either continue to Chapter 2 to get an overview of the application you will build, or go directly to Chapter 3 and start building it.
Copyright © 2004, Sun Microsystems, Inc. All rights reserved.