I'm working on a Grails application that needs to connect to a Oracle database using a LDAP context. The URL format is something like the following:
jdbc:oracle:thin:@ldap://tns.mycompany.com:389/marketing,cn=OracleContext,dc=com,dc=marketing
I'm also not using the Grails DataSource.groovy configuration for this. I'm managing a separate DataSource in the resources.groovy using Spring DSL. I'm using the org.springframework.jdbc.datasource.DriverManagerDataSource. I have not tried this with the standard DataSource.groovy stuff. When I first tried using this, I would get an exception with the following text: "javax.naming.NotContextException Not an instance of DirContext". There seems to be a bug with the Spring LDAP and the SimpleNamingContextBuilder class. Basically the SimpleNamingContextBuilder returns a Context implementation, not a DirContext implementation. You can work around this in Grails by adding the following to the Config.groovy file:
grails.naming.entries = null
Problem solved. The DataSource now bootstraps correctly and I can go on my merry way. Kudos to Luke Daley for bringing this to my attention.