• Non ci sono risultati.

Explanation of the Changes to the Pet Store Demo

Nel documento Oracle9AS Containers for J2EE (pagine 55-58)

You may be curious as to what is the difference between the 1.1.2 Pet Store demo available off of the Sun Microsystems site and the modified one we have provided.

This section will discuss the modifications we made.

Although the development of J2EE applications is standardized and portable, the XML configuration files are not. You may have to configure multiple XML files before deploying any application to OC4J. The configuration necessary depends on the services that your application uses. For example, if your application uses a database, you must configure itsDataSource object.

For basic applications, such as Pet Store, you normally deploy the application using the wizard and configure anyDataSource necessary for this application. Before deployment, you must create a manifest for the application within the

application.xml file. This can be included in addition to or in replacement of a MANIFEST.MF file. This file must be properly configured and included within the J2EE EAR file that is to be deployed.

Simple applications—including the Pet Store application—require the following basic steps:

Basic Step Pet Store Step Description Pet Store

Step(s) 1. Create or obtain the

application.

Create the J2EE application or obtain it from another party.

1

2. Make any necessary server environment changes.

Set theJAVA_HOME variable. 2

3. Modify any application XML configuration files.

The Pet Store application should have the appropriate header in theweb.xml configuration file.

4

4. Update the application manifest file.

Place theapplication.xml file in the appropriate directory.

5

5. Build an EAR file including the application—if one does not already exist.

Use ANT to build an EAR file. 6

6. Deploy application EAR file. On the OC4J Home Page of Enterprise Manager, clicking the Deploy EAR File button starts a deployment wizard.

7

7. Configure the database used. Add the data source to either the global or local data source configuration.

8

Configuring the Pet Store Web Application Demo

The following steps describe what modifications to make to deploy the Pet Store application into OC4J.

1. We asked you to download the Pet Store demo from the Oracle OTN site. You could download it from the Sun Microsystems site and make these

modifications yourself.

2. Make any necessary server environment changes. You must set theJAVA_HOME variable to the base directory of the Java 2 SDK.

3. Modify theerrorpage.jsp to import the appropriate IO package. Add<%@

page import ="java.io.*" isErrorPage="true" %> to the jps1.1.2/src/petstore/src/docroot/errorpage.jsp file.

This command prevents the Pet Store error page from throwing a

"PrintWriter class not found exception".

4. Modify any deployment descriptors in the application as necessary.

a. Modify theweb.xml configuration file to contain the correct header. In jps1.1.2/src/petstore/src/docroot/WEB-INF/web.xml, replace

"Java 2 Enterprise Edition Reference Implementation" with

"Oracle9iAS Containers for J2EE".

This step, which is optional, updates the application server type of OC4J.

b. Change the database type in the EJB deployment descriptor provided with the Pet Store application. This step enables data-access objects to work with an Oracle database instead of a Cloudscape database, which is the

configured database type in the Pet Store application.

Injps1.1.2/src/components/customer/src/customer_ejb.xml, replaceOrderDAOCS withOrderDAOOracle.

5. Update the application manifest file. For the Pet Store application, you must create anapplication.xml to act as the manifest file for the Pet Store demo and place it into thejps1.1.2/src/petstore/src/ directory. OC4J uses theapplication.xmlfile as the manifest file. See theapplication.xmlfile that was downloaded in thejps112.zip from OTN.

6. Build an EAR file including the application. After modifying the key XML files within this application, rebuild the Pet Store application to integrate these configuration changes.

a. Modify the contents of/src/petstore/src/build.xml to build the EAR file with the OC4J modifications.

b. Executejps1.1.2/src/petstore/src/build.bat in a DOS shell.

Configuring the Pet Store Web Application Demo

You can also double-click on thebuild.bat file in Windows Explorer to execute this file. Thebuild.bat file uses ANT. To learn more about the ANT file, go to the following Jakarta site:

http://jakarta.apache.org/ant/

7. Configure an Oracle database in the OC4JDataSource definition.

a. Copy the data source object definition from thedata-sources.xml file contained in theconfig.zip into the Enterprise Manager data source configuration.

b. Connect as SYS in SQL*Plus to add theestoreuserand grant it privileges by executing the following SQL command:

grant connect, resource, create session to estoreuser identified by estore

8. Deploy the application using the deployment wizard off the OC4J Home Page.

9. Start both the OHS and the OC4J server.

For instructions on configuring and starting the OHS, see the Oracle HTTP Server Administration Guide.

10. Open your Web browser and then specify the following URL:

http://<ohs_host>:<ohs_port>/estore

The Pet Store splash screen appears. Follow the instructions provided by the Pet Store application to load the Java Pet Store database tables.

Nel documento Oracle9AS Containers for J2EE (pagine 55-58)