Installing the Oracle9i XML Product Order Application

Table of Contents

Required Software

Back To Top
  • Oracle9i Database version 9.2 or above downloadable from OTN.
  • OC4J (Oracle9iAS containers for J2EE) Release 9.0.3 Production downloadable from OTN.
  • JDK(Java Developer's Kit) version 1.3 or higher downloadable from http://java.sun.com (or) Oracle9i JDeveloper version 9.0.3 downloadable from OTN .
  • Oracle XDK(XML Developer's Kit) for java downloadable from OTN.
  • ANT tool for building the Enterprise ARchive (EAR) file which can be downloaded from Jakarta Apache
  • Any JavaScript and XML enabled browser.

    Note:
    => This sample has been certified with Red Hat Linux Advanced Server 2.1, Solaris 5.6 and Windows NT 4.0, Windows 2000.
    =>
    Best viewed with browsers Netscape Navigator 6 or above, Microsoft Internet Explorer 5 or above. On Linux, best viewed with the Mozilla 1.3 or above browser.

Notations Used

Back To Top

This section will describe the terms used in the document.
For example,

Notation Description
JAVA_HOME Folder where JDK1.3 or above is installed. For example, C:\jdk13 or /home/jdk13
XDK_HOME Folder where you have extracted Oracle9i XDK for Java utility . For example, C:\xdk or /home/xdk
OC4J_HOME Folder where OC4J is installed. For example, C:\oc4j or /home/oc4j
ANT_HOME Folder where ANT is installed. For example, C:\ant or /home/ant
   

Extracting the source code

Back To Top

The application files are stored in an archive named ProductOrder.jar. Download the archive and extract it to a convenient directory. Execute following command to extract  the files:

     jar xvf ProductOrder.jar

The archive ProductOrder.jar extracts the files that implement the Product Order System. All the files are extracted into the "ProductOrder" directory.

Configuring the application

Back To Top


Creating the Product Order Schema

To create the Product Order schema follow the steps below :

  1. In Sql*Plus, Login to your Oracle9i Database using a user with sysdba privilege. For ex:
    sqlplus> connect sys/change_on_install@db_alias as sysdba;


  2. Now, create a new user with the required privileges using the following commands in Sql*Plus :
    sqlplus> CREATE USER orderuser IDENTIFIED BY orderuser;
    sqlplus> GRANT connect,resource TO orderuser;


  3. Then, login as the user created above from Sql*Plus and run the script CreateTables.sql under
    the ProductOrder/sql directory extracted above. For example :

    sqlplus> @<your_directory_path>\ProductOrder\sql\CreateTables.sql

    This script will create all the tables, constraints, sequence and triggers required for the application.

Setting up JDK Environmental Variables

Note:
=> This application has been certified for Korn Shell in Solaris and Linux. All the instructions for Solaris
and Linux pertains to the Korn shell in it. You can enter into Korn Shell in Solaris and Linux by typing "ksh" on
the command prompt.

=> Setting the environmental variables is not required when you are compiling java files with Oracle 9i JDeveloper.


  1. Set the JAVA_HOME environment variable.


  2. Eg. For Windows - set JAVA_HOME=<JAVA_HOME>
    Eg. For Solaris and Linux - export JAVA_HOME=/usr/java1.3


  3. Set the PATH environmental variable
    Eg. For Windows - set PATH=%JAVA_HOME%\bin;%XDK_HOME%/bin
    Eg. For Solaris and Linux - export PATH=$JAVA_HOME/bin:$XDK_HOME/bin:


  4. Add ANT to the PATH only for EAR deployment
    Eg. For Windows - set PATH=%JAVA_HOME%\bin;%XDK_HOME%/bin;%ANT_HOME%/bin
    Eg. For Solaris and Linux - export PATH=$JAVA_HOME/bin:$XDK_HOME/bin:
  5. $ANT_HOME/bin

  6. Set the CLASSPATH environmental variable. Make sure that classpath visits following jars.
    These files are part of XDK and OC4J.
    XDK_HOME\lib\xmlparserv2.jar
    XDK_HOME\lib\xschema.jar
    XDK_HOME\lib\xsu12.jar
    XDK_HOME\lib\classgen.jar
    XDK_HOME\lib\oraclexsql.jar
    OC4J_HOME\j2ee\home\oc4j.jar
    OC4J_HOME\j2ee\home\lib\servlet.jar

    Note : In addition to the above jar files, add the current directory to the CLASSPATH environment variable.

Eg. For Windows -
set CLASSPATH=%CLASSPATH%; %XDK_HOME%\lib\oraclexsql.jar;
%XDK_HOME%\lib\xmlparserv2.jar;%XDK_HOME%\lib\ xschema.jar;
%XDK_HOME%\lib\classgen.jar;%OC4J_HOME%\j2ee\home\oc4j.jar;%OC4J_HOME%\j2ee\home\lib\servlet.jar;.

Eg. For Solaris and Linux -
export CLASSPATH=$CLASSPATH:$XDK_HOME/lib/oraclexsql.jar:$XDK_HOME/lib/xmlparserv2.jar:
$XDK_HOME/lib/xschema.jar:$XDK_HOME/lib/classgen.jar:$OC4J_HOME/j2ee/home/oc4j.jar:
$OC4J_HOME/j2ee/home/lib/servlet.jar:.

Setting up OC4J for XML9i Class Generator and XSQL pages

  1. Copy the classgen.jar from the XDK_HOME\lib directory to the OC4J_HOME\j2ee\home\lib directory.
  2. Copy the oraclexsql.jar, xmlparserv2.jar, xschema.jar and xsu12.jar archives from the XDK_HOME\lib
    directory to the OC4J_HOME\j2ee\home\lib directory.
  3. Copy the XSQLConfig.xml file in the XDK_HOME\xdk\admin directory to the OC4J_HOME\j2ee\home\lib directory.
  4. Setting up the database connection for XSQL Pages : To setup the database connection,

    a) Edit the XSQLConfig.xml file in the j2ee\home\lib directory and add the following connection
    information within the <connectiondefs>...</connectiondefs> tags :
    <connection name="otn9i">
    <username>orderuser</username>
    <password>orderuser</password>
    <dburl>jdbc:oracle:thin:@hostname:port:sid</dburl>
    <driver>oracle.jdbc.driver.OracleDriver</driver>
    </connection>

    where,
    username - is the name of the database user created above i.e orderuser
    password
    - is the password of the orderuser user i.e orderuser
    hostname - is the hostname of the machine where Oracle9i database is running.
    port - is the port on the hostname where the database listener is listening to.
    sid - is the sid of your database.
    Note: Do not change the connection name 'otn9i' used above since all the XSQL pages use this to
    make the database connection.

    b) Make sure that in the same XSQLConfig.xml file edited in step a, the value for the <factory> tag inside
    <connection-manager>...</connection-manager> tags is set to the default
    value i.e oracle.xml.xsql.XSQLConnectionManagerFactoryImpl.
  5. Go to OC4J_HOME\j2ee\home\config directory.
  6. Add the following entries to global-web-application.xml to recognize the .xsql pages under
    <web-app>...</web-app> tags.

    <servlet>
    <servlet-name>xsql</servlet-name>
    <servlet-class>oracle.xml.xsql.XSQLServlet</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>xsql</servlet-name>
    <url-pattern>/*.xsql</url-pattern>
    </servlet-mapping>

Using ORACG utility

The 'ORACG' command line utility of Oracle9i XDK is used to generate java classes as below.
Make sure that you have XDK_HOME/bin is in your PATH.

  • Go to ProductOrder/xml directory. At the command prompt do the following:
    java oracle.xml.classgen.oracg -comment -schema ProductOrder.xsd -package oracle.otnsamples.ProductOrder

  • This will create .java files for the ProductOrder.xsd under ProductOrder/xml inside the directory "oracle".
    The .java files created will be: Customer.java, Products.java, ProductOrder.java.

 

Deploying the sample application in OC4J

Back To Top

Simple Deployment

Note: You can compile the source code with either JDK 1.3 or Oracle9i JDeveloper.

    Compiling the sources with Oracle9i JDeveloper

    1. Copy the oracle directory created by ORACG which is in ProductOrder/Xml directory to ProductOrder/java directory..
    2. Open Oracle9i JDeveloper.
    3. Go to ProductOrder directory which got created while extracting the jar and open ProductOrder.jws
    4. Expand ProductOrder.jws node by clicking it.
    5. Expand ProductOrder.jpr node by clicking it. You can view entire source for OrderXmlBean.java, PoInsertHandler.java, ProductOrder.java, Customer.java and Products.java.
    6. Right click ProductOrder.jpr
    7. Select “Project Settings…” from pop up menu
    8. In the node Common -> Input Paths, edit java source path and ensure that “java” directory is part of the path where the source files are found.
    9. Expand Configurations node from left hand panel.
    10. Expand Development node
    11. Click on Libraries node in left panel
    12. In the available libraries box in the left hand panel click on “Oracle XML parser v2” and click on single right
      handed arrow in the middle. This will add the library in current project.
    13. Similarly, select Servlet Runtime, XSQL Runtime to add them to current project.
    14. Next, click on New button in this dialog box
    15. New library dialog pops up
    16. Enter library name as “mypo”
    17. Click on Edit button for CLASSPATH entry.
    18. In the Edit Class Path windowclick Add Entry button
    19. Select XDK_HOME\lib\xschema.jar;XDK_HOME\lib\classgen.jar
    20. Here, in the available libraries box in the right hand panel click on “mypo” and click on single right handed arrow in the middle. This will add the library in current project. Then, click OK for all other open windows .
    21. Compile all the files .
    22. Oracle9i JDeveloper creates a classes directory inside “ProductOrder” directory where we can find compiled class files.

    Compiling the Java Sources with JDK 1.3

    Note: This application has been certified for Korn Shell in Solaris and Linux. All the instructions for Solaris and Linux pertains to the Korn shell in it. You can enter into Korn Shell in Solaris and Linux by typing "ksh" on the command prompt.

    Following steps need to be followed if we are compiling the java sources using jdk:

    • Go to the ProductOrder/java directory where we have extracted the java sources.
      The directory contains two java files i.e OrderXmlBean.java and PoInsertHandler.java.
    • Copy the oracle directory created by ORACG which is in ProductOrder/Xml directory to ProductOrder/java directory.
    • Compile all the files using the command.
      javac -d . *.java

    Copying and Running the application to OC4J

    1. Copy the “ProductOrder” directory extracted to the OC4J_HOME\j2ee\home\default-web-app\examples\jsp directory of your OC4J installation.
    2. Go to OC4J_HOME\j2ee\home\default-web-app\WEB-INF\classes directory.
    3. Create drill-down directory structure as below:
      oracle->otnsamples->ProductOrder
    4. Copy all .class EXCEPT PoInsertHandler.class to ProductOrder directory created above.
    5. Go to OC4J_HOME\j2ee\home\lib directory.
    6. Create drill-down directory structure as below:oracle->otnsamples->ProductOrder->xml->xsql->actions
    7. Copy PoInsertHandler.class to actions directory created above.
    8. Restart the oc4j server.
    9. Access the main page of the application using the URL :

    http://<oc4jserver>:<port-no>/examples/jsp/ProductOrder/jsps/Welcome.jsp

    where,
    <oc4jserver> - is the hostname / ip-address of the machine where OC4J is installed.
    <port-no> - is the port number on which oc4j server is listening. Default port is 8888.


EAR(Enterprise ARchive) Deployment

Back To Top


Note:
=> Ensure that you have downloaded and installed “ANT” tool (refer required software).
=> Ensure that you have JDK 1.3 or higher installed as it is required for compilation of the .java sources which builds the EAR file
=> ANT_HOME\bin is in the PATH.

  1. Go to ProductOrder/xml directory where you have extracted the sample.
  2. Move the oracle directory to ProductOrder/java directory. Make sure that ProductOrder/xml does not have oracle directory.
  3. Delete all .class files if you have them when doing the simple deployment.
  4. Go to the root ProductOrder directory and type ant.
  5. ANT generates ProductOrder.ear file and places it under “build” directory.

Running the application

  1. Move ProductOrder.ear file under OC4J_HOME\j2ee\home\applications directory.
  2. Go to OC4J_HOME\j2ee\home\config directory
  3. Edit http-web-site.xml file.
  4. Add following entry under <web-site ……….> tag
    <web-app application="ProductOrder" name="ProductOrder"   root="/ProductOrder"/>
  5. Save this file
  6. Open server.xml file and add the following entry
    <application name="ProductOrder" path="../applications/ProductOrder.ear" />
  7. Re-start the OC4J Server.
  8. Then, access the Application using the URL :

    http://<oc4jserver>:<port-no>/ProductOrder/jsps/Welcome.jsp

where,
<oc4jserver> - is the hostname / ip-address of the machine where OC4J is installed.
<port-no> - is the port number on which oc4j server is listening. Default port is 8888.

 
E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy