4

Usually my Grails app is run on Tomcat. I recently was making it work for Weblogic. I followed all the notes here: notel reference link And my app does work on Weblogic, but... I have a problem in how the datasource works...

Having this in my DataSource.groovy file:

production {
    dataSource {
        dbCreate = "validate"
        resourceRef="true"
        jndiName = "java:/comp/env/jdbc/myGrails"

Makes it work on Tomcat. But it won't work on Weblogic.

Having this in my DataSource.groovy file:

production {
    dataSource {
        dbCreate = "validate"
        resourceRef="true"
        jndiName = "jdbc/myGrails"

Makes it work on Weblogic, but then not on Tomcat.

How can I configure the jndiName in Datasource.groovy to have it work on both Weblogic and Tomcat?

I did read through this post: Tomcat vs Weblogic JNDI Lookup But couldn't find a solution that worked for me. I might not have understood since it was geared more towards Spring (which I don't know very well) and not specifically Grails. Hoping someone can help me with a Grails/Datasource.groovy solution.

Community
  • 1
  • 1
user542103
  • 255
  • 3
  • 18
  • have you tried using [datasource-jndi-declare](http://grails.org/plugin/datasource-jndi-declare) plugin? Have not tested it but looks like this will resolve the discrepancy. The plugin just makes sure that if there are JNDI names provided in datasource then it omits the container prefix and adds resource-ref in web descriptor. Give it a shot. I will look into it as well. Here is the [gist of plugin's implementation](https://github.com/fzilic/grails-datasource-jndi-declare/blob/master/src/groovy/org/grails/plugins/datasourcejndideclare/UpdateWebDescriptor.groovy). – dmahapatro Mar 14 '14 at 18:44

1 Answers1

0

Kept searching and found this solution... It worked! Nice and simple too.

How to specify portable jndi datsource lookup in grails

Community
  • 1
  • 1
user542103
  • 255
  • 3
  • 18