Saturday, February 9, 2008

Configuring JNDI location for Composite applications

Developing J2EE applications through Jdeveloper IDE and deploying them to the target application server is an easy process but not widely accepted deployment method/pattern. Ant script is a widely accepted solution to achieve this.

Irrespective of which method you are using for deployment, you must setup the JNDI location as part of the application server. This is required to have a reusable managed connection on the server that is properly configured with various attributes such as caching, timeouts and other advanced attributes like “fastConnectionFailoverEnabled” etc.

Following is the procedure to setup this

Connection Pool Creation
  1. Login to Enterprise Manager website (ex: Server.Client.com:7777/em).
  2. Goto specific OC4J Instance / Administration / JDBC Resources.
  3. Create a new Connection pool named ‘App1’ (This may be typically the application name) by feeding the jdbc URL (remember to list all nodes if is a Oracle RAC database), user name and password.
  4. Click on the Attributes tab and verify the values as appropriate to your architecture.
  5. Click Apply.

Managed Data Source Creation

  1. Create a data source named “App1” by selecting “Managed Data Source” option name, default application name and set the JNDI Location to “jdbc/app1” and select "App1" connection pool. It is important to match this location name with what is defined in the Jdeveloper project.

JDeveloper

  1. Now, de-select the “Bundle Default data-sources.xml During Deployment” option from your Jdeveloper. This option can be found in Tools menu / Preferences option / Deployment section. This action will prevent it from copying your jdeveloper connections to the application server, if you are using JDeveloper for your deployment.
  2. Delete connection pool and data source related to the old Jdeveloper’s JNDI Location ‘jdbc/jdev-app1’, if any already created/exist.
  3. Test the application. If the app is working, continue to next step.

Connection Failure Configuration for Oracle RAC

  1. If you are using Oracle RAC environment, it is important to configure this Connection Pool for RAC to detect the connection failures and balance the conection to the appropriate RAC node. Now set the Connection Factory Properties named “connectionCachingEnabled”, “fastConnectionFailoverEnabled” with a value of “true” in the ‘App1’ connection pool definition. It is also important to have these properties created in the order mentioned by clicking the button "Add Another Row".

Now your application is ready to use the connection pool's user and password rather the user/password that you have embeded as part of the ear file from JDeveloper.

No comments: