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.
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 extractthe files:
jar xvf ProductCatalog.jar
The archive ProductCatalog.jar
extracts the files that implement the Product Catalog System
To create the Product Catalog schema
follow the steps below :
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;
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;
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 :
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.
Set the JAVA_HOME environment variable.
Eg. For Windows - set
JAVA_HOME=<JAVA_HOME>
Eg. For Solaris and Linux - export JAVA_HOME=/usr/java1.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:
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:
$ANT_HOME/bin
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 :
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.
Copy the batik.jar from
FOP_HOME\lib and fop.jar from the
FOP_HOME directory to
the OC4J_HOME\j2ee\home\lib directory.
Copy xsqlserializers.jar
from XDK_HOME\lib to OC4J_HOME\j2ee\home\lib
directory.
Edit XSQLConfig.xml present
in OC4J_HOME\j2ee\home\lib
directory.
Create an alias for FOP serializer by
including the following in the file between <XSQLConfig>
... </XSQLConfig> tags.
Note: You can compile the source code with either JDK 1.3 or
Oracle9i JDeveloper.
Compiling the sources with
Oracle9i JDeveloper
Open Oracle9i JDeveloper .
Go to ProductCatalog directory which got created while extracting
the jar.
Open ProductCatalog.jws
Expand ProductCatalog.jws node by clicking it.
Expand ProductCatalog.jpr node by clicking it. You can view all the
source files
Right click ProductCatalog.jpr
Select Project Settings from pop up menu
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.
Expand Configurations node from left hand panel.
Expand Development node
Click on Libraries node in left panel
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.
Similarly, select Servlet Runtime to add them to current project.
Next, click on New button in this dialog box
New library dialog pops up
Enter library name as mypc
Click on Edit button for CLASSPATH entry.
In the Edit Class Path windowclick Add Entry button
Select XDK_HOME\lib\xschema.jar and OC4J_HOME\jdbc\lib\classes12dms.jar
Click OK for all other open windows .
Compile all the files .
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
Copy the “ProductCatalog” directory extracted to the OC4J_HOME\j2ee\home\default-web-app\examples\jsp
directory of your OC4J installation.
Go to OC4J_HOME\j2ee\home\default-web-app\WEB-INF\classes
directory.
Create drill-down directory structure as below:
oracle=>otnsamples=>ProductCatalog
Copy FileUpload.class to ProductCatalog
directory created above.
Go to OC4J_HOME\j2ee\home\lib directory.
Create drill-down directory structure as below:oracle=>otnsamples=>ProductCatalog=>xml=>xsql=>actions
Copy all .class files EXCEPT Fileupload.class
to actions directory created above.
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.
Restart the oc4j server.
Access the main page of the application using the URL :
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.
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:
Go to ProductCatalog directory where
you have extracted the sample.
Delete all .class files if you have them when doing the
simple deployment.
Go to the root ProductCatalog directory and type ant.
ANT generates ProductCatalog.ear file and places it under build
directory.
Go to OC4J_HOME\j2ee\home\config directory
to find the following files.
Edit http-web-site.xml file.
Add following entry under <web-site ……….>
tag
<web-app application="ProductCatalog" name="ProductCatalog"root="/ProductCatalog"/>
Save this file
Open server.xml file and add the following
entry
<application name="ProductCatalog" path="../applications/ProductCatalog.ear"
/>
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"
/>
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.
Restart the OC4J Server.
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.