Applications running on Enterprise Server often require access to resources stored in an external JNDI repository. For example, generic Java objects might be stored in an LDAP server according to the Java schema. External JNDI resource elements let you configure such external resource repositories.
The following topics are addressed here:
Use the create-jndi-resource subcommand in remote mode to register an external JNDI resource.
The external JNDI factory must implement the javax.naming.spi.InitialContextFactory interface.
Ensure that the server is running.
Remote subcommands require a running server.
Register an external JNDI resource by using the create-jndi-resource(1) subcommand.
Information on properties for the subcommand is contained in this help page.
Restart Enterprise Server.
See To Restart a Domain.
In This example sample_jndi_resource is registered.
asadmin> create-jndi-resource --jndilookupname sample_jndi --restype queue --factoryclass sampleClass --description "this is a sample jndi resource" sample_jndi_resource Command create-jndi-resource executed successfully |
You can also view the full syntax and options of the subcommand by typing asadmin help create-jndi-resource at the command line.
Use the list-jndi-resources subcommand in remote mode to list all existing JNDI resources.
Ensure that the server is running.
Remote subcommands require a running server.
List the existing JNDI resources by using thelist-jndi-resources(1) subcommand.
This example lists the JNDI resources.
asadmin> list-jndi-resources jndi_resource1 jndi_resource2 jndi_resource3 Command list-jndi-resources executed successfully |
You can also view the full syntax and options of the subcommand by typing asadmin help list-jndi-resources at the command line.
Use the list-jndi-entries subcommand in remote mode to browse and list the entries in the JNDI tree. You can either list all entries, or you can specify the JNDI context or subcontext to list specific entries.
Ensure that the server is running.
Remote subcommands require a running server.
List the JNDI entries for a configuration by using the list-jndi-entries(1) subcommand.
This example lists all the JNDI entries for the naming service.
asadmin> list-jndi-entries jndi_entry03 jndi_entry72 jndi_entry76 Command list-jndi-resources executed successfully |
You can also view the full syntax and options of the subcommand by typing asadmin help list-jndi-entries at the command line.
List the existing JNDI resources by using thelist-jndi-resources(1) subcommand.
Use the set(1) subcommand to modify an external JNDI resource.
This example modifies an external resource.
asadmin> set server.resources.external-jndi-resource.my-jndi-resource. jndi-lookup-name=bar server.resources.external-jndi-resource.my-jndi-resource.jndi-lookup-name=bar |
Use the delete-jndi-resource subcommand in remote mode to remove a JNDI resource.
Ensure that the server is running.
Remote subcommands require a running server.
Remove an external JNDI entry by using the delete-jndi-resource(1) subcommand.
This example deletes an external JNDI resource:
asadmin> delete-jndi-resource jndi_resource2 Command delete-jndi-resource executed successfully. |
You can also view the full syntax and options of the subcommand by typing asadmin help delete-jndi-resource at the command line.
<resources> <!-- external-jndi-resource element specifies how to access J2EE resources -- stored in an external JNDI repository. This 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>