Grails

ConfigurationHolder.config null inside DataSource.groovy for WAR builds

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Not A Bug
  • Affects Version/s: 1.2.1
  • Fix Version/s: 1.2.1
  • Component/s: Configuration
  • Labels:
    None

Description

It appears as though there's a regression in 1.2.1 that revives GRAILS-4673.

My use case is to define the jndi name at a central place (I deemed Config.groovy appropriate for this purpose) so it can be picked up from both _Events.groovy and DataSource.groovy.

For constant values there is a trival work-around though: Use plain old Java or Groovy Constants and put them anywhere down your src... folders

public abstract /*utility*/ class Const {
    private Const() { /*never*/ }

    public static final String JNDI_NAME = "dofr-webservice";
}

and then...

production {
    dataSource {
      pooled = false
      // jndiName = "java:comp/env/jdbc/${ConfigurationHolder.config.jndiName}"
      jndiName = "java:comp/env/jdbc/${Const.JNDI_NAME}"
    }

Activity

Hide
Reiner Saddey added a comment -

I couldn't find any specification stating configuration file parsing order (which appears to change over time), so I think this is not a bug at all.

Show
Reiner Saddey added a comment - I couldn't find any specification stating configuration file parsing order (which appears to change over time), so I think this is not a bug at all.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: