How to Setup Oracle Connection Pooling with Oracle Application Server 10g using JNDI/JDBC
Posted at Tuesday, March 07, 2006
A previous post addresses setting up Oracle Connection Pools and the corresponding JNDI resource for Apache/Tomcat. This post aims to do the same, only this time, for Oracle's Application Server (10g OAS).
Assumptions:
A compatible JDK is already installed and included in your path. Likewise, it is assumed that %JAVA_HOME% is set and resides within your permanent System environment %PATH%. I used the JDK that came with JDeveloper for both the development and as the JDK the Standalone Oracle Application Server uses.
Setting up the Example:
Download Oracle Application Server Containers for J2EE Standalone from Oracle - I used version 10.1.3.0.0, build#060119.
Install Oracle Application Server Containers for J2EE Standalone by
referencing the Standalone User's Guide: Standalone User's Guide. Instead of relying upon the official documentation for the installation, I read the readme.txt file immediate after unzipping the distribution for detailed, distribution-specific installation information.
In my case (adjust accordingly for path differences, etc.):
You will receive the following prompt at the command line; enter and confirm password when prompted:
Visit the index page -- in my case, http://localhost:8888/ -- to verify that the Standalone Application Server is functioning.
I created a test application using JDeveloper - first_j2ee - that can be used to validate your set-up (Note: Right-click 'Save Target As'):
Source ¦ first_j2ee.ear
Deploy the Sample Application via (adjust -file and password values as appropriate):
Next, bind the Sample Application:
Load the Static HTML Page in order to verify successful deployment and subsequent binding. The body of the page should read: 'The first_j2ee application has been deployed successfully!'.
I have packaged along with the application's source, the data-sources.xml file that you need to move and edit in order to accomplish this.
Assumptions:
A compatible JDK is already installed and included in your path. Likewise, it is assumed that %JAVA_HOME% is set and resides within your permanent System environment %PATH%. I used the JDK that came with JDeveloper for both the development and as the JDK the Standalone Oracle Application Server uses.
Setting up the Example:
Download Oracle Application Server Containers for J2EE Standalone from Oracle - I used version 10.1.3.0.0, build#060119.
Install Oracle Application Server Containers for J2EE Standalone by
referencing the Standalone User's Guide: Standalone User's Guide. Instead of relying upon the official documentation for the installation, I read the readme.txt file immediate after unzipping the distribution for detailed, distribution-specific installation information.
In my case (adjust accordingly for path differences, etc.):
mkdir c:\oc4j_standalone
cd c:\oc4j_standalone
unzip c:\temp\oc4j_extended_101300.zip
set JAVA_HOME=c:\jdev10g\jdk
set ORACLE_HOME=c:\oc4j_standalone
set PATH=%JAVA_HOME%\bin;%ORACLE_HOME%\bin;%PATH%
oc4j -start
You will receive the following prompt at the command line; enter and confirm password when prompted:
Enter password: ********
Confirm password: ********
Confirm password: The password for OC4J administrator "oc4jadmin" has been set.
06/03/07 15:08:59 The OC4J administrator "oc4jadmin" account is activated.
2006-03-07 15:09:11.959 NOTIFICATION JMS Router is initiating ...
06/03/07 15:09:14 Oracle Containers for J2EE 10g (10.1.3.0.0) initialized
Visit the index page -- in my case, http://localhost:8888/ -- to verify that the Standalone Application Server is functioning.
I created a test application using JDeveloper - first_j2ee - that can be used to validate your set-up (Note: Right-click 'Save Target As'):
Source ¦ first_j2ee.ear
Deploy the Sample Application via (adjust -file and password values as appropriate):
set ORACLE_HOME=c:\oc4j_standalone
set PATH=%ORACLE_HOME%\bin;%PATH%
cd j2ee
cd home
java -jar admin.jar ormi://localhost:23791 oc4jadmin password -deploy -file c:/temp/first_j2ee.ear -deploymentName first_j2ee
[ 2006-03-13 10:03:51.625 PST ] Application Deployer for first_j2ee STARTS.
[ 2006-03-13 10:03:51.672 PST ] Copy the archive to C:\oc4j_standalone\j2ee\home
\applications\first_j2ee.ear
[ 2006-03-13 10:03:51.719 PST ] Initialize C:\oc4j_standalone\j2ee\home\applications\first_j2ee.ear begins...
[ 2006-03-13 10:03:51.719 PST ] Unpacking first_j2ee.ear
[ 2006-03-13 10:03:51.812 PST ] Done unpacking first_j2ee.ear
[ 2006-03-13 10:03:51.812 PST ] Unpacking first_j2ee.war
[ 2006-03-13 10:03:51.922 PST ] Done unpacking first_j2ee.war
[ 2006-03-13 10:03:51.938 PST ] Initialize C:\oc4j_standalone\j2ee\home\applications\first_j2ee.ear ends...
[ 2006-03-13 10:03:51.938 PST ] Starting application : first_j2ee
[ 2006-03-13 10:03:51.938 PST ] Initializing ClassLoader(s)
[ 2006-03-13 10:03:51.938 PST ] Initializing EJB container
[ 2006-03-13 10:03:51.938 PST ] Loading connector(s)
[ 2006-03-13 10:03:52.219 PST ] Starting up resource adapters
[ 2006-03-13 10:03:52.219 PST ] Initializing EJB sessions
[ 2006-03-13 10:03:52.219 PST ] Committing ClassLoader(s)
[ 2006-03-13 10:03:52.219 PST ] Initialize first_j2ee begins...
[ 2006-03-13 10:03:52.234 PST ] Initialize first_j2ee ends...
[ 2006-03-13 10:03:52.234 PST ] Started application : first_j2ee
[ 2006-03-13 10:03:52.250 PST ] Application Deployer for first_j2ee COMPLETES. O peration time: 625 msecs
Next, bind the Sample Application:
java -jar admin.jar ormi://localhost:23791 oc4jadmin password -bindwebapp first_j2ee first_j2ee default-web-site /first_j2ee
Load the Static HTML Page in order to verify successful deployment and subsequent binding. The body of the page should read: 'The first_j2ee application has been deployed successfully!'.
I have packaged along with the application's source, the data-sources.xml file that you need to move and edit in order to accomplish this.
Extract and move the data-sources.xml file to your %ORACLE_HOME%\j2ee\home\application-deployments\first_j2ee directory. This is the *.xml file that defines the connection pool resource, etc. Modify the following elements/attributes for your environment:
- url - to reflect your database service
- username - to reflect the username you want to connect with (must have select on v$instance for this example to work)
- password - to reflect the password for the aforementioned username
Once the aforementioned modificaions have been made, test via: http://localhost:8888/first_j2ee/TestJNDI. If successful, the page will return the value of the instance and host name for the database service you specified in data-sources.xml.
Labels: Application Servers, JAVA
