Petstore Demo

来源:百度文库 编辑:神马文学网 时间:2024/04/25 07:11:28

Run 2001 J2EETMDeployathon Online!
With Oracle9iAS Containers for J2EETM 1.0.2.2 

  IntroductionStep1:Download and Install JavaTM 2 SDK,Standard Edition
Step2:Download OC4J
Step3: Installand Configure OC4J
Step4: Downloadthe Java Pet Store Application
Step5: Installand Configure the Java Pet Store Application
Step6: Runthe Java Pet Store Application with an Oracle Database
Notes
Support

Step 1:Download and InstallJava 2 SDK, Standard Edition

Oracle9iAS Containersfor J2EE1.0.2.2, requires Java 2 SDK, Standard Edition v1.3.0_02 or v1.2.2_07for moredetails, check certificationmatrix .  If Java 2, Standard Edition v1.3.0_02 or v1.2.2_07 is notalreadyinstalled on your platform, you need to install it now, from http://java.sun.com/j2se. 

Step 2: DownloadOracle9iASContainers for J2EE (OC4J)

Download the latestOC4J from OC4Jdownload page on OTN

Step 3: Installand ConfigureOC4J

To install the serverand setthe administrative password:
  • unzip oc4j.zip 
  • change  to directory (/home)
  • java -jar orion.jar -install
  • follow the instructions provided by the installation program.

Step 4: Downloadthe JavaPet Store Application 

You can download thelatestJava Pet Store Application (version 1.1.2) from the JavaTM Pet Store 1.1.2 Release page

Step 5: Installand Configurethe Java Pet Store Application

  • Set the environment variable JAVA_HOME to the base directory where you installed the Java 2 SDK. For example, set JAVA_HOME to ~/jdk1.3.0_02 or ~/jdk1.2.2_07
  • Configure OC4J  DataSource for an Oracle database
    • Copy  PetStore_data_source into /config/data-sources.xml 
    • or alternatively add PetStore_data_Sources entries to /config/data_sources.xml
    • Create user estoreuser with password estore
    • Grant connect, resource and create session privileges to  estoreuser
  • Unzip the downloaded application in a directory of your choice ()
  • Configure the PetStore Application to work with an Oracle database
    • Change to the directory that contains the expanded PetStore application ()
    • In order to enable Data Access Objects to work against an Oracle database instead of Cloudspace (the default), in /src/components/customer/src/customer_ejb.xml, replace OrderDAOCS with OrderDAOOracle 
  • In order to work around a PetStore Application bug which faults PetStore errorpage to throw a "PrintWriter class Not Found Exception", add the following statement to  /src/petstore/src/docroot/errorpage.jsp
      <%@ page import ="java.io.*"  isErrorPage="true" %> 
  • Update the Application Server Type
    • in /src/petstore/src/docroot/WEB-INF/web.xml 
              
          no description
          server/ServerType
          Java 2 Enterprise Edition Reference Implementation
          java.lang.String
         
              replace "Java 2 Enterprise Edition Reference Implementation" with "Oracle9iAS Containers for J2EE"
  • Rebuild the Application to integrate configuration changes

  • In order to remove J2EE R.I. dependencies in /src/petstore/src/build.xml
     

    • J2EE_HOME is not used, but checked in build.sh, we suggest to set it to any valid directory path
    • Replace the content of /src/petstore/src/build.xml with  oc4j_build.xml 
    • Copy application.xml into /src/petstore/src/
    • Copy manifest.mf into /src/petstore/src/
    • Change to  /src/petstore/src/
    • Invoke build.sh (Unix) or build.bat (Windows)
  • Deploy  the PetStore Application on OC4J Server
    •  Copy petstore.ear from the  /src/petstore/build/ into /applications/
    • In /config/server.xml, uncomment application entries and add the petstore entry as follows:
              
     
    • In /config/default-web-site.xml, uncomment web-app entries and add the petstore entry as follows:
              
       
  • Start the server
    • To start the server:
              java -jar orion.jar
               or
              java -jar orion.jar -config /config/server.xml
                  "Oracle9iAS Containers for J2EE 1.0.2.2 - Up and running"

Step 6: Run the Java Pet Store Application

  • Open your Web browser.
  • Specify the URL: http://localhost:8888/pestore
  • Follow the instructions provided by the petstore application to load java Pet Store database tables

Notes

  • You do not have to access the Java Pet Store application to check that the Oracle9iAS Containers for J2EE  server is running. Simply point your browser to http://hostname:port, where hostname is the host on which the OC4J  server is running, and port is the default port number to which the OC4J server is listening. For example, point to: http://localhost:8888
  • The instructions for deploying PetStore in step 5 assume local deployment, in order to deploy to a remote OC4J instance use the fololowing command:

  • java -jar admin.jar ormi://localhost -deploy -file petstore.ear -deploymentName petstore
     
  • To shut down OC4J, gracefully,  issue the following command, from directory: 

  • % java -jar admin.jar ormi://localhost/ -shutdown
    If it does not shut down the container, force a rapid shut down by passing the force argument, as follows: 
    % java -jar admin.jar ormi://localhost/ -shutdown force
    For the unlikely situation where none of these work, kill OC4J process(es) with your operating system command
  • Note: OC4J release 1.0.2.2 is pre-configured with thin JDBC driver for Oracle8.0, Oracle8i databases; to run OC4J against an Oracle9i database,  replace classes12.jar in /lib/ with the one shipped with Oracle9i DB
  • You can run the PetStore with OC4J using a database other than Oracle8i.  If you would like to use another database with OC4J, please check the "Using Merant Drivers" section in Using OC4J 

Support

  • For questions related to running the Deployathon on Oracle9iAS Containers for J2EE, Please see the Oracle9iAS J2EE.
  • The J2EEblueprints interest list is the place to get answers to generic questions about the Deployathon. To join the interest list, send an email to listserv@java.sun.com. Specify subscribe j2eeblueprints-interest yourlastname yourfirstname in the body of the email.