1. phillip_green_idmworks
  2. Weblogic JNDI Custom Resource Configuration

Overview

HTTPS SSH

Introduction

Unlike other application servers (JBoss, Glassfish, Tomcat, ...) WebLogic (as of 10g) doesn't support any way of adding custom resources into JNDI (Custom resource in JNDI on different application servers). While searching for a solution I found weblogic-jndi-startup. While I felt the implementation wasn't inline with what I wanted, the theory was a pretty simple solution. weblogic-jndi-startup is more generic in that it can load an object that has a constructor with a single String argument. I have made multiple Initializers for more specific use cases.

Installation

Installation requires copying weblogic-jndi-custom-resource-configuration-1.x.x.jar into the classpath of WebLogic:

cp weblogic-jndi-custom-resource-configuration-1.x.x.jar $WEBLOGIC_DOMAINS/$SERVER/lib

Once the jar has been added to the classpath, you can add Initializers as Startup Classes.

WebLogic's Startup and Shutdown Classes

WebLogic provides a way to run classes during Startup and Shutdown. The class is run by calling main() with a configured argument string.

Install Initializer

To add a Startup Class:

  1. Connect to WebLogic Administration Console.
  2. Navigate to $DOMAIN->Environment->Startup and Shutdown Classes
  3. Click "New"
  4. Select "Startup Class"
  5. Click "Next"
  6. Enter any value for "Name"
  7. Enter the class of the desired Initializer (com.idmworks.weblogic.jndiconfiguration.StringInitializer)
  8. Click "Next"
  9. Select Desired Targets
  10. Click "Finish"

Configure Initializer

In the previous section, the Initializer has been added, but not configured.

  1. Click on the recently created Startup Class
  2. Update "Arguments" with the arguments to be passed to the Initializer (read below for expected arguments format)
  3. Tick "Run Before Application Activations" (this makes sure the Initializer is ran before any applications are started)
  4. Click "Save"
  5. Restart WebLogic

Initializers

Initializers are classes configured as Startup Classes. They add objects to JNDI based on the arguments of their configuration. Below is each type of Initializer with configuration details.

StringInitializer

class: com.idmworks.weblogic.jndiconfiguration.StringInitializer

Description

Places a String Object at a particular JNDI Location.

Arguments Format

[jndiName=StringToAdd]*

Example

jsf/ProjectStage=Development server/node=Test

The above argument would add "Development" to JNDI at the location of jsf/ProjectState and "Test" at the location of server/node

PropertiesInitializer

class: com.idmworks.weblogic.jndiconfiguration.PropertiesInitializer

Description

Loads Properties from a location and places it at a particular JNDI Location.

Arguments Format

[jndiName=pathToProperties]*

Example

properties/myAppConfiguration=/etc/myApp/config/myapp.properties

The above argument would Load the properties found at /etc/myApp/config/myapp.properties and add it JNDI at location properties/MyAppConfiguration

LdapDirContextInitializer

class: com.idmworks.weblogic.jndiconfiguration.LdapDirContextInitializer

Description

Bound to the specified JNDI Location will be a DirContext factory that will generate DirContexts that can be used to connect to the LDAP. The specified properties will contain the connection information.

Required connection properties:

  • java.naming.provider.url

Optional connection properties:

  • java.naming.factory.initial
  • java.naming.security.credentials
  • java.naming.security.principal

Arguments Format

[jndiName=pathToConnectionProperties]*

Example

ldap/myLdap=/etc/myApp/config/myldap-connection.properties

The above argument would Load the properties found at /etc/myApp/config/myldap-connection and add it JNDI at location ldap/myLdap__properties. At location ldap/myLdap will be the DirContext.

References