How to specify jndi datsource porting to grails

I know that finding JNDI in grails is as simple as

datasource {
  jndiName = "java:comp/env/myDataSource"
}

This works great on Tomcat.

In other containers (WebLogic, JBOSS, etc.) jndiName for the same object will be simple myDataSource. The question is how to configure it as universal and portable so that the code does not need to be changed depending on the purpose of the deployment?

0
source share
1 answer

Perhaps you can disable the system property, which, as you know, will be set when working in Tomcat, and not elsewhere, for example.

datasource {
  jndiName = "${System.getProperty('catalina.home') ? 'java:comp/env/' : ''}myDataSource"
}
+1
source

Source: https://habr.com/ru/post/1531825/


All Articles