Installing the BC4J Toy Store on Apache Tomcat 4.1.24
Several customers have asked how to install the BC4J Toy Store Demo under Apache Tomcat 4.1.24. Here are the steps:
- Download the BC4J Toy Store Demo distribution in which I've updated the configuration parameters for the toystore.model.services.ToyStoreService application module to use the more portable JDBC datasource names like java:comp/env/jdbc/toystoreDS instead of the existing jdbc/toystoreDS names which Tomcat does not support (Oracle9iAS and some other containers support both syntaxes).
NOTE: This is now just the standard BC4J Toy Store Demo download on OTN as of about December 10th, 2003.
- Create the
BC4JToyStore.war web archive file.
After opening the BC4JToyStore.jws workspace in JDeveloper 9.0.3, expand the Deployment.jpr project, and select the BC4JToyStore.deploy deployment profile. Select Deploy to WAR file from the right-mouse context menu.
- Deploy the BC4JToyStore.war file just produced to Tomcat by copying it from the
./bc4jtoystore/deploy directory, to the TOMCAT_HOME/webapps directory.
- Install the required supporting libraries for BC4J web applications.
Copy the JAR files listed in the table below from JDEVHOME to TOMCAT_HOME/common/lib .
JAR File Name |
Description |
./bc4j/lib/bc4jmt.jar |
BC4J Core Middle Tier Libraries |
./bc4j/lib/bc4jct.jar |
BC4J Client Libraries |
./bc4j/lib/bc4j_jclient_common.jar |
BC4J Common Client Data Model Support |
./bc4j/lib/bc4jhtml.jar |
BC4J Web Application Support |
./bc4j/jlib/bc4jdatum.jar |
BC4J Base Domain Support |
./bc4j/lib/bc4jdomorcl.jar |
BC4J Oracle Domains |
./bc4j/lib/bc4jimdomains.jar |
BC4J Oracle Intermedia Domains |
./ord/jlib/ordhttp.jar |
Oracle Intermedia HTTP Upload Support |
./ord/jlib/ordim.jar |
Oracle Intermedia |
./sqlj/lib/runtime12.jar |
SQLJ Runtime (Used by Intermedia) |
./jlib/jdev-cm.jar |
JDeveloper Connection Manager |
./jdev/lib/jdev-rt.jar |
JDeveloper Runtime Event Instrumentation |
./jdbc/lib/classes12.jar |
Oracle JDBC Driver |
./jdbc/lib/nls_charset12.jar |
Oracle JDBC Driver NLS Support |
./lib/xmlparserv2.jar |
Oracle XML Parser |
./lib/oraclexsql.jar |
Oracle XSQL Pages Templating Engine |
./rdbms/jlib/xsu12.jar |
Oracle XML SQL Utility (Used by XSQL) |
- Configure the Tomcat-specific setup for the two JDBC datasources requiredThe BC4J Toy Store demo's web.xml file contains the following two resource reference definitions for JDBC datsources named
jdbc/toystoreDS and jdbc/toystore_statemgmtDS :
<resource-ref>
<res-ref-name>jdbc/toystoreDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<res-ref-name>jdbc/toystore_statemgmtDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
This is the J2EE container-independent resource definition which is always paired with container-specific setup information for these resources. To provide the Tomcat-specific datasource configuration details for the "/BC4JToyStore " web application context, edit the TOMCAT_HOME /conf/server.xml file, and find the place inside the appropriate Host element, where you can paste the additional BC4J Toy Store Context definition. It will look like this:
<Server>
<Service>
<Engine>
<Host>
:
<Context>
<!-- Existing other <Context> entries -->
</Context>
:
<!--
| Paste in Entire <Context> element show below right here
+-->
</Host>
</Engine>
</Service>
</Server> Paste in the following BC4J Toy Store Context entry at the indicated location. You will need to edit the value of the JDBC url parameter to have the appropriate @machine:port:sid string to match the database where you have created the TOYSTORE and TOYSTORE_STATEMGMT users and installed the BC4J Toy Store tables.
<!--
| BEGIN BC4J Toy Store Tomcat DataSource Config Section
+-->
<Context path="/BC4JToyStore" docBase="BC4JToyStore">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_BC4JToyStore."
suffix=".log"
timestamp="true"/>
<!--
| Using the oracle.jdbc.pool.OracleDataSourceFactory factory class
| the valid values for the 'type' attribute below are:
|
| 1. oracle.jdbc.pool.OracleDataSource
| 2. oracle.jdbc.pool.OracleConnectionPoolDataSource
| 3. oracle.jdbc.xa.client.OracleXADataSource
| 4. oracle.jdbc.pool.OracleConnectionCacheImpl
| 5. oracle.jdbc.pool.OracleOCIConnectionPool
|
| If you specify either "oracle.jdbc.pool.OracleConnectionCacheImpl"
| or "oracle.jdbc.pool.OracleOCIConnectionPool" you can supply
| additional children <parameter> entries of the corresponding
| <ResourceParams> element below to set the values of a number
| of additional configuration parameters.
|
| For "oracle.jdbc.pool.OracleConnectionCacheImpl", additional
| optional parameters are:
|
| minLimit
| maxLimit
| cacheScheme
|
| For "oracle.jdbc.pool.OracleOCIConnectionPool", additional
| optional parameters are:
|
| connpool_min_limit
| connpool_max_limit
| connpool_increment
| connpool_active_size
| connpool_pool_size
| connpool_timeout
| connpool_nowait
| transactions_distributed
|
| Consult the Oracle JDBC documentation for more info on what
| the the values of these parameters mean and how they can be
| used to tune the connection pool implementation.
|
+-->
<Resource name="jdbc/toystoreDS"
auth="Container"
type="oracle.jdbc.pool.OracleConnectionPoolDataSource"/>
<Resource name="jdbc/toystore_statemgmtDS"
auth="Container"
type="oracle.jdbc.pool.OracleConnectionPoolDataSource"/>
<ResourceParams name="jdbc/toystoreDS">
<parameter>
<name>factory</name>
<value>oracle.jdbc.pool.OracleDataSourceFactory</value>
</parameter>
<!--
| You might need to change the "@machine:port:SID" part of the JDBC URL below
| to match your target database. The value below is for a default Oracle
| database running on the same machine as Tomcat.
+-->
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:toystore/toystore@127.0.0.1:1521:ORCL<;/value>
</parameter>
</ResourceParams>
<ResourceParams name="jdbc/toystore_statemgmtDS">
<parameter>
<name>factory</name>
<value>oracle.jdbc.pool.OracleDataSourceFactory</value>
</parameter>
<!--
| You might need to change the "@machine:port:SID" part of the JDBC URL below
| to match your target database. The value below is for a default Oracle
| database running on the same machine as Tomcat.
+-->
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:toystore_statemgmt/toystore@127.0.0.1:1521:ORCL<;/value>
</parameter>
</ResourceParams>
</Context>
<!--
| END BC4J Toy Store Tomcat DataSource Config Section
+-->
- Test the JDBC Datasource Configuration The BC4J Toy Store Demo comes with a testing servlet in the ToyStoreController.jpr project named
toystore.controller.TestJDBCDatasources . The web.xml file is pre-configured to map this servlet to the path "/testjdbcdatasources ". So, by pointing your browser at the URL:http://yourtomcatmachine:yourport/BC4JToyStore/testjdbcdatasources You will see the following returned in the browser if the two required datasources are properly configured:
Successfully looked-up 'java:comp/env/jdbc/toystoreDS' DataSource
Successfully issued a ROLLBACK command using connection from this datasource
Successfully looked-up 'java:comp/env/jdbc/toystore_statemgmtDS' DataSource
Successfully issued a ROLLBACK command using connection from this datasource
After you have performed these steps, you should be able to point your browser at:
http://yourtomcatmachine:yourport/BC4JToyStore
to run the BC4J Toy Store demo on Tomcat.
|