Tuesday, 24 February 2009

How to Create a JDBC/OCI Connection Pool For Stand Alone OC4J 10.1.3.x

Recently I had to setup JDBC/OCI connection pool in stand alone OC4J 10.1.3.x using an oracle client The problem here is OC4J 10.1.3.x comes with JDBC driver of ojdbc14.jar. Which means you will have issues using the oracle client libraries.

As a result of that you must upgrade the driver to use the client version JDBC driver as well as set various environment variables before starting stand alone OC4J. The steps are as follows.

Note: This is based on OC4J and on a windows environment, using instant client

1. Download instant client as follows, in my case installed in directory as follows


You can download the version from here.


2. Open up command window and set environment variables as follows

set PATH=D:\jdev\instant-clients\10203;%PATH%
set TNS_ADMIN=D:\jdev\instant-clients\10203

Note: A tnsnames.ora exists in the directory D:\jdev\instant-clients\10203 and has the following entry which I will use in stand alone OC4J shortly.

(ADDRESS = (PROTOCOL = TCP)(HOST = xxxx.au.oracle.com)(PORT = 1522))
(SERVICE_NAME = linux10g)

3. Start stand alone OC4J as follows, ensuring you use the same commend window from step 2 above.

set ORACLE_HOME=D:\jdev\stand-alone-oc4j\10134
set JAVA_HOME=D:\jdev\jdevprod\10134\jdk

D:\jdev\stand-alone-oc4j\10134\bin>oc4j -start
Starting OC4J from D:\jdev\stand-alone-oc4j\10134\j2ee\home ...
09/02/23 13:42:29 Oracle Containers for J2EE 10g ( initialized

4. OC4J 10.1.3.x is using JDBC driver which means it will have issues connecting using instant client so we have to upgrade the JDBC driver to as shown below for the whole container. Follow this metalink note to fix that so it matches the same version of instant client which would mean you use ojdbc14.jar from jar file of ojdbc14.jar.

Note 420303.1 - How to Use The Latest Thin JDBC Driver Across All Applications For a 10.1.3.x OAS Container

You can download the JDBC driver jar file from this link, but it should be available in your oracle client install.


5. Stop stand alone OC4J to pick up the shared library change.
6. Start stand alone OC4J.
7. Create a data source as follows.

<connection-pool name="ocitest-pool">
<connection-factory factory-class="oracle.jdbc.pool.OracleDataSource"
user="scott" password="tiger" url="jdbc:oracle:oci:@LINUX10G"/>

For more information on data sources refer to the following documentation.

Oracle® Containers for J2EE Services Guide
10g (
Part Number B28958-01

Thursday, 19 February 2009

OC4J 10.1.3.x start order of Resource Adapters

In order to control the start order of Resource Adapters for an application you can use the start-order tag as described here in the docs within your oc4j-connectors.xml

Oracle® Containers for J2EE Resource Adapter Administrator's Guide
10g (
Part Number B28956-01

Thursday, 12 February 2009

Determine the Security Providers for the JVM

Note for myself: While working with Oracle's JDBC/THIN driver with SSL this comes in handy

package pas.test;

import java.security.Provider;
import java.security.Security;

public class GetProviders
public GetProviders()

public static void main(String[] args)
Provider[] pl = Security.getProviders();
System.out.println("Printing Available Security.getProviders()");
for (int i=0; i < pl.length; i++)
System.out.println("\n" + i + ". " + pl[i].toString());
System.out.println("Name: " + pl[i].getName());
System.out.println("Version: " + pl[i].getVersion());
System.out.println("Info: " + pl[i].getInfo());


Printing Available Security.getProviders()

0. SUN version 1.5
Name: SUN
Version: 1.5
Info: SUN (DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom; X.509 certificates; JKS keystore; PKIX CertPathValidator; PKIX CertPathBuilder; LDAP, Collection CertStores)

1. SunRsaSign version 1.5
Name: SunRsaSign
Version: 1.5
Info: Sun RSA signature provider

2. SunJSSE version 1.5
Name: SunJSSE
Version: 1.5
Info: Sun JSSE provider(PKCS12, SunX509 key/trust factories, SSLv3, TLSv1)

3. SunJCE version 1.5
Name: SunJCE
Version: 1.5
Info: SunJCE Provider (implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, Diffie-Hellman, HMAC)

4. SunJGSS version 1.0
Name: SunJGSS
Version: 1.0
Info: Sun (Kerberos v5)

5. SunSASL version 1.5
Name: SunSASL
Version: 1.5
Info: Sun SASL provider(implements client mechanisms for: DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5; server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5)

Thursday, 5 February 2009

Oracle Weblogic 10.3 / RAC 11g Integration How To

I worked with product management to create a how to for Oracle Weblogic 10.3 / RAC 11g Integration. The URL is on OTN now as follows. It comes with a sample web application to test your configuration out as well.


It comes with a white paper as well created by a product manager


Monday, 2 February 2009

Using Log4J with Jdeveloper 11g / Integrated Weblogic Server

A quick demo on how to use Log4j within a JDeveloper workspace for 11g when running web projects. In this example we are using a simple HTTP servlet with just a doGet method defined

1. Create the default "log4j.properties" file within the root src folder of your web project.

# **Set root logger level to DEBUG and its only appender to A.
log4j.rootLogger=DEBUG, A
# ***** A is set to be a ConsoleAppender.
# ***** A uses PatternLayout.

log4j.appender.A.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n


2. Add the log4j JAR file to the project's web-inf/lib directory for runtime and as a project library JAR file for compile time. In my case I used the JAR file as follows

> log4j-1.2.15.jar

3. Here is the servlet code which will then use log4j at runtime.

package pas.au.log4j;

import java.io.IOException;
import java.io.PrintWriter;
import org.apache.log4j.Category;
import org.apache.log4j.PropertyConfigurator;
import java.util.Properties;
import java.io.FileInputStream;

import javax.servlet.*;
import javax.servlet.http.*;

import org.apache.log4j.Logger;

public class Log4JServletDemo
extends HttpServlet
Logger log = Logger.getLogger(this.getClass().getSimpleName());
private static final String CONTENT_TYPE = "text/html; charset=windows-1252";

public void init(ServletConfig config)
throws ServletException
log.info("init() method of servlet Log4JServletDemo");

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
PrintWriter out = response.getWriter();
out.println("<h2>Log4j demo</h2>");

log.info("init() doGet method of servlet Log4JServletDemo");


4. When run within the "Integrated Weblogic Server" verify runtime output as follows within JDeveloper's log window.

Target URL --
0 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] INFO Log4JServletDemo - init() method of servlet Log4JServletDemo
63 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] INFO Log4JServletDemo - init() doGet method of servlet Log4JServletDemo

When your ready to create a WAR file for deployment to an External Weblogic 10.3 server then the log4j.properties file should be added to the web-inf/classes folder automatically with this setup.