Pages

Sunday, May 25, 2008

Using OpenLDAP for net8 and AQ connection factory

In this blog I will show you can use OpenLDAP to lookup your Oracle Net (tnsnames) connections or AQ connection factories. Now you don't need to have an Oracle Internet Directory (OID) installed. The first step is to download openldap. Install this and download my oracle.schema and put this in the schema folder of openldap. This file has to be included in the slapd.conf.Edit slapd.conf and add"include schema/java.schema" "include schema/oracle.schema" .Make sure anonymous can read the tnsnames entries.access to dn="" by * readaccess to * by self write by users read by anonymous readWe have to configure the ldap for Oracle by making an OracleContext and oracledbconnections entry. I do this with ldapbrowser. You can download it here. For this free java application I made some templates which you can use.

Do the same for oracledbconnections ( this is for the AQ entries) Now use the queue template in ldapbrowser.

To make a tnsnames entry I select the OracleContext ldap entry and I use the orclNetService template to create a new Oracle connection.

We are ready to use it, we only has to create ldap.ora in the network\admin folder. The ldap.ora looks like this.DIRECTORY_SERVERS= (localhost:389:636)

DEFAULT_ADMIN_CONTEXT = "o=sgi,c=us"

DIRECTORY_SERVER_TYPE = OID

We start sqlplus and use the ldap name as tnsnames entry. I can also start net manager and go the Directory menuitem to see our ldap entry

The second part shows you can lookup an AQ connection factory with JNDI and ldap. first let's register a new connection in the ldap server. For this I only need the following jars files. jndi-1.2.1.jar,jta-1.0.1.jar, jms-1.1.jar,aqapi.jar and the jdbc jar of oracle

But when we try to send a message to the queue, the following error is thrown :javax.naming.NamingException: problem generating object using object factory [Root exception is java.lang.NullPointerException]; remaining name 'cn=messagequeue_aq, cn=OracleDBQueues, ou=queues, ou=tms, ou=services, o=nhs' at com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:1052) at com.sun.jndi.toolkit.ctx.ComponentContext.p_lookup(ComponentContext.java:526) at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup(PartialCompositeContext.java:159) at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup(PartialCompositeContext.java:148) at javax.naming.InitialContext.lookup(InitialContext.java:351) at src.java.servlet.Test.main(Test.java:58)Caused by: java.lang.NullPointerException at oracle.jms.AQjmsDestinationFactory.getObjectInstance(AQjmsDestinationFactory.java:120) at javax.naming.spi.DirectoryManager.getObjectInstance(DirectoryManager.java:176) at com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:1045) ... 5 more

It seems the queue object is not getting created due to insufficient /invalid attribures.

Hi,Thanks for help..I managed with your schema in ApcheDS and successfully registered my connection factory. As pointed in this post[1], I have created a queue object under 'OracleDBQueues"..But when i do lookup it gives null//codeQueue queue = (Queue) destctxQF.lookup("cn=ratha.test");

Hi,Thanks for help..I managed with your schema in ApcheDS and successfully registered my connection factory. As pointed in this post[1], I have created a queue object under 'OracleDBQueues"..But when i do lookup it gives null//codeQueue queue = (Queue) destctxQF.lookup("cn=ratha.test");

javax.naming.NamingException: problem generating object using object factory [Root exception is java.lang.NullPointerException]; remaining name 'cn=ratha.test' at com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:1070) at com.sun.jndi.toolkit.ctx.ComponentContext.p_lookup(ComponentContext.java:526) at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup(PartialCompositeContext.java:159) at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup(PartialCompositeContext.java:148) at OracleAQJNDIClient.get_Factory_from_LDAP(OracleAQJNDIClient.java:107) at OracleAQJNDIClient.main(OracleAQJNDIClient.java:155)Caused by: java.lang.NullPointerException at oracle.jms.AQjmsDestinationFactory.getObjectInstance(AQjmsDestinationFactory.java:120) at javax.naming.spi.DirectoryManager.getObjectInstance(DirectoryManager.java:176) at com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:1063)

javax.naming.NamingException: problem generating object using object factory [Root exception is java.lang.NullPointerException]; remaining name 'cn=ratha.test' at com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:1070) at com.sun.jndi.toolkit.ctx.ComponentContext.p_lookup(ComponentContext.java:526) at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup(PartialCompositeContext.java:159) at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup(PartialCompositeContext.java:148) at OracleAQJNDIClient.get_Factory_from_LDAP(OracleAQJNDIClient.java:107) at OracleAQJNDIClient.main(OracleAQJNDIClient.java:155)Caused by: java.lang.NullPointerException at oracle.jms.AQjmsDestinationFactory.getObjectInstance(AQjmsDestinationFactory.java:120) at javax.naming.spi.DirectoryManager.getObjectInstance(DirectoryManager.java:176) at com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:1063)

Hi,Thanks for the help..I managed it..After adding "orcldbaqgeneric: maxretries=3", i'm able to connect to my queue..Not sure how that solved the issue..(i don't have any network issue..)BTW, your posts are really helpful..

ex Oracle ACE , Java Developer of the year 2009. Co-writer of the OSB Development Cookbook.I am working as a Software Architect and specialized in CI,CD, integration, middleware, security and web development.