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 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 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.


class: com.idmworks.weblogic.jndiconfiguration.StringInitializer


Places a String Object at a particular JNDI Location.

Arguments Format



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


class: com.idmworks.weblogic.jndiconfiguration.PropertiesInitializer


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

Arguments Format




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


class: com.idmworks.weblogic.jndiconfiguration.LdapDirContextInitializer


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

Arguments Format




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.