Sun Java System Application Server Enterprise Edition 8.1 2005Q2 Administration Guide

- Previous: About Custom Resources
- Next: Chapter 7 Connector Resources

# About External JNDI Repositories and Resources

- Using External JNDI Repositories and Resources

- To create an external resource

- To edit an external resource

- To delete an external resource

- Listing External Resources

## Using External JNDI Repositories and Resources

Often applications running on the Application Server require access to resources stored in an external JNDI repository. For example, generic Java objects could be stored in an LDAP server as per the Java schema. External JNDI resource elements let users configure such external resource repositories. The external JNDI factory must implement `javax.naming.spi.InitialContextFactory` interface.

An example of the use of an external JNDI resource is:

    <resources>
     <!-- external-jndi-resource element specifies how to access J2EE resources
     -- stored in an external JNDI repository. The following example
     -- illustrates how to access a java object stored in LDAP.
     -- factory-class element specifies the JNDI InitialContext factory that
     -- needs to be used to access the resource factory. property element
     -- corresponds to the environment applicable to the external JNDI context
     -- and jndi-lookup-name refers to the JNDI name to lookup to fetch the
     -- designated (in this case the java) object.
     -->
      <external-jndi-resource jndi-name="test/myBean"
          jndi-lookup-name="cn=myBean"
          res-type="test.myBean"
          factory-class="com.sun.jndi.ldap.LdapCtxFactory">
        <property name="PROVIDER-URL" value="ldap://ldapserver:389/o=myObjects" />
        <property name="SECURITY_AUTHENTICATION" value="simple" />
        <property name="SECURITY_PRINCIPAL", value="cn=joeSmith, o=Engineering" />
        <property name="SECURITY_CREDENTIALS" value="changeit" />
      </external-jndi-resource>
    </resources>

## To create an external resource

1. In the left pane of the Admin Console, open the Application Server instance for the JNDI configuration to be modified.

2. Open JNDI and select External Resources.

   If any external resources have been created already, they are listed in the right pane.

3. To create a new external resource, click New.

4. In the JNDI Name field, enter the name that is to be used to access the resource.

   This name is registered in the JNDI naming service.

5. In the Resource Type field, enter a fully qualified type definition, as shown in the example above.

   The Resource Type definition follows the format, `xxx.xxx`.

6. In the JNDI Lookup field, enter the JNDI value to look up in the external repository.

   For example, when creating an external resource to connect to an external repository, to test a bean class, the JNDI Lookup can look like this: `cn=`testmybean.

7. In the Factory Class field, enter a JNDI factory class external repository, for example, `com.sun.jndi.ldap`.

   This class implements the `javax.naming.spi.ObjectFactory` interface.

8. In the Description field, enter a description for the resource to be created.

   This description is a string value and can include a maximum of 250 characters.

9. In the Additional Properties section, add the property name and value.

10. Mark the External Resource Enabled checkbox, to enable the external resource.

11. Click OK to save the external resource.

    If the external resource is deployed on a cluster or a stand-alone instance, you can manage targets using the Targets tab. The tab appears after the external resource has been created. Set the target by entering the target name and clicking OK.

##### Equivalent asadmin command

`create-jndi-resource`

## To edit an external resource

1. In the left pane of the Admin Console, open the Application Server instance for the JNDI configuration to be modified.

2. Open JNDI and select External Resources.

   If any external resources have been created already, they are listed in the right pane.

3. To edit an external resource, click on the file name in the right pane.

4. Edit the Resource Type field, the JNDI Lookup field, the Factory Class field, or the Description field.

5. Mark the External Resource Enabled checkbox, to enable the external resource.

6. Click Save to save the changes to the external resource.

## To delete an external resource

1. In the left pane of the Admin Console, open the JNDI tab.

2. Click External Resources.

   If any external resources have been created already, they are listed in the right pane.

3. Click the box next to the name of the resource to be deleted.

4. Click Delete. The external resource is deleted.

##### Equivalent asadmin command

`delete-jndi-resource`

## Listing External Resources

To list external resources, type the `asadmin list-jndi-resources` command and specify the JNDI name. For example, to list an external resource, type the following:

`$asadmin list-jndi-resources --user adminuser --host plum jndi_name_test`

For the full context, type `asadmin help list-jndi-resources`.

- Previous: About Custom Resources
- Next: Chapter 7 Connector Resources

- © 2010, Oracle Corporation and/or its affiliates