Installing the Oracle9i XML Product Catalog 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
  • Apache FOP downloadable from xml.apache.org. Download fop 0.19.0 from this page.
  • Any Postscript Reader to view PDF document.
  • 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 tool is extracted. For example, C:\ant or /home/ant
FOP_HOME Folder where you have extracted Apache FOP. For example, C:\fop or /home/fop

Extracting the source code

Back To Top

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

     jar xvf ProductCatalog.jar

The archive ProductCatalog.jar extracts the files that implement the Product Catalog System

Configuring the application

Back To Top


Creating the Product Catalog Schema

To create the Product Catalog 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 catalog IDENTIFIED BY catalog;
    sqlplus>
    GRANT connect,resource to catalog;
    sqlplus>
    GRANT create any index to catalog;
    sqlplus>
    GRANT query rewrite to catalog;

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

    sqlplus>
    @<your_directory_path>\ProductCatalog\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\oraclexsql.jar
    OC4J_HOME\j2ee\home\oc4j.jar
    OC4J_HOME\jdbc\lib\classes12dms.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;
%OC4J_HOME%\j2ee\home\oc4j.jar;%OC4J_HOME%\jdbc\lib\classes12dms.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:
$OC4J_HOME/j2ee/home/oc4j.jar:$OC4J_HOME/jdbc/lib/classes12dms.jar:
$OC4J_HOME/j2ee/home/lib/servlet.jar:.

Setting up OC4J for 9iXML Class Generator and XSQL pages

1. Copy the oraclexsql.jar, xmlparserv2.jar, xsu12.jar and xschema.jar archives from
the XDK_HOME\lib directory to the OC4J_HOME\j2ee\home\lib directory.
2. Copy the XSQLConfig.xml file in the XDK_HOME\xdk\admin directory to the OC4J_HOME\j2ee\home\lib directory.
3. Setting up the database connection for XSQL Pages : To setup the database connection,
edit
the XSQLConfig.xml file in the OC4J_HOME\j2ee\home\lib directory and replace the
following connection- pool and connection-manager tags in the XSQLConfig.xml file between
<XSQLConfig>...</XSQLConfig> tags :

<connection-pool>
<initial>10</initial>
<increment>1</increment>
<timeout-seconds>60</timeout-seconds>
<dump-allowed>no</dump-allowed>
</connection-pool>

<connection-manager>
<factory>oracle.otnsamples.ProductCatalog.xml.xsql.actions.MyXSQLConnectionManagerFactoryImpl</factory>
</connection-manager>

4. Go to OC4J_HOME\j2ee\home\config directory.
5. 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>

6. Go to ProductCatalog/java directory and edit MyXSQLConnectionManagerImpl.java

7. Search for 'connect' method in the file. Replace insn104a.idc.oracle.com:1522:otn9idb in the
connect method with your hostname:port:database_sid and save the file.

Setup XSQL pages for FOP

Apache FOP (Formatting Objects Processor) is a Java utility that reads a formatting object tree and then turns it into a PDF document.

    1. Copy the batik.jar from FOP_HOME\lib and fop.jar from the FOP_HOME directory to
      the OC4J_HOME\j2ee\home\lib directory.
    2. Copy xsqlserializers.jar from XDK_HOME\lib to OC4J_HOME\j2ee\home\lib directory.
    3. Edit XSQLConfig.xml present in OC4J_HOME\j2ee\home\lib directory.
    4. Create an alias for FOP serializer by including the following in the file between <XSQLConfig> ... </XSQLConfig> tags.

      <serializerdefs>
      <serializer>
      <name>Sample</name>
      <class>oracle.xml.xsql.serializers.XSQLSampleSerializer</class>
      </serializer>
      <serializer>
      <name>FOP</name>
      <class>oracle.xml.xsql.serializers.XSQLFOPSerializer</class>
      </serializer>
      </serializerdefs>

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. Open Oracle9i JDeveloper .
    2. Go to ProductCatalog directory which got created while extracting the jar.
    3. Open ProductCatalog.jws
    4. Expand ProductCatalog.jws node by clicking it.
    5. Expand ProductCatalog.jpr node by clicking it. You can view all the source files
    6. Right click ProductCatalog.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 exists inside the “ProductCatalog” directory where we extracted the sample.
    9. Expand Configurations node from left hand panel.
    10. Expand Development node
    11. Click on Libraries node in left panel
    12. Check if the library “XSQL Runtime” is added in the right hand panel. If not, from the available libraries box in the left hand panel click on “XSQL Runtime” and click on single right handed arrow in the middle. This will add the library into current project.
    13. Similarly, select Servlet 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 “mypc”
    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 and OC4J_HOME\jdbc\lib\classes12dms.jar
    20. Click OK for all other open windows .
    21. Compile all the files .
    22. Oracle9i JDeveloper creates a classes directory inside “ProductCatalog” 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 ProductCatalog/java directory where we have the .java source files.
    • Compile all the files using the command.
      javac -d . *.java
    • This will create a drill down directory oracle =>otnsamples =>ProductCatalog => xml => xsql =>actions under the ProductCatalog/java directory.
    • FileUpload.class will be under oracle =>otnsamples => ProductCatalog and rest in actions directory.

     

    Copying and Running the application to OC4J

    1. Copy the “ProductCatalog” 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=>ProductCatalog
    4. Copy FileUpload.class to ProductCatalog directory created above.
    5. Go to OC4J_HOME\j2ee\home\lib directory.
    6. Create drill-down directory structure as below:oracle=>otnsamples=>ProductCatalog=>xml=>xsql=>actions
    7. Copy all .class files EXCEPT Fileupload.class to actions directory created above.
    8. Stop the OC4J server if it is running. Goto the OC4J_HOME\lib directory. Rename the xmlparserv2.jar file to xmlparserv2.oc4jjar. Then, copy the xmlparserv2.jar file from XDK_HOME\lib directory to OC4J_HOME\lib directory.
    9. Restart the oc4j server.
    10. Access the main page of the application using the URL :

    http://<oc4jserver>:<port-no>/examples/jsp/ProductCatalog/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.

Using ANT tool:

  1. Go to ProductCatalog directory where you have extracted the sample.
  2. Delete all .class files if you have them when doing the simple deployment.
  3. Go to the root ProductCatalog directory and type ant.
  4. ANT generates ProductCatalog.ear file and places it under build directory.

Running the application:

  1. Move ProductCatalog.ear file under OC4J_HOME\j2ee\home\applications directory.
  2. Go to OC4J_HOME\j2ee\home\config directory to find the following files.
  3. Edit http-web-site.xml file.
  4. Add following entry under <web-site ……….> tag
    <web-app application="ProductCatalog" name="ProductCatalog"   root="/ProductCatalog"/>
  5. Save this file
  6. Open server.xml file and add the following entry
    <application name="ProductCatalog" path="../applications/ProductCatalog.ear" />
  7. Open Application.xml in OC4J_HOME\j2ee\home\config directory and add an entry between
    <orion-application> ....</orion-application> tags as below.
    <library path="../../home/ProductCatalog/ProductCatalog/WEB-INF/classes" />
  8. Stop the OC4J server if it is running. Goto the OC4J_HOME\lib directory. Rename the xmlparserv2.jar file to xmlparserv2.oc4jjar. Then, copy the xmlparserv2.jar file from XDK_HOME\lib directory to OC4J_HOME\lib directory.
  9. Restart the OC4J Server.
  10. Then, access the Application using the URL :
    http://<oc4jserver>:<port-no>/ProductCatalog/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