grails-core icon indicating copy to clipboard operation
grails-core copied to clipboard

Unable to load application.groovy while running bootRun target

Open weinellucian opened this issue 9 months ago • 1 comments

Expected Behavior

We are seeing issue while starting the Grails App using bootRun, our Application do have lot of configuration specified in grails-app/conf/application.groovy one such configuration is grails.config.locations as shown below, the configuration files have App specific and DB configurations. During App startup we see issue loading application.groovy resulting in Application not coming up.

application.groovy
grails.config.locations = [
        XYZ_DB_CONFIG:  "XYZ_configuration.groovy",
        XYZ_APP_CONFIG: "XYZApp_configuration.groovy"
]

Analysis:

After debugging the Grails codebase we do see issue in grails-core where the class GroovyConfigPropertySourceLoader.groovy responsible for loading the configurations is using deprecated class NavigableMap , in GroovyConfigPropertySourceLoader.load() method in this method we see the following happening

  1. groovy.util.ConfigObject is been constructed from ConfigSlurper using application.groovy wich has all the configurations specified in application.groovy
  2. Further NavigableMap.merge(configObject, false) seems to be not working i.e. we see empty NavigableMap as shown in the debug snapshot

Image

Actual Behaviour

No response

Steps To Reproduce

No response

Environment Information

Windows 11 Pro grails-7.0.0-M1 JDK 17

Example Application

No response

Version

grails-7.0.0-M1

weinellucian avatar Mar 26 '25 08:03 weinellucian

Can you please provide a sample application that reproduces this?

We have tried to reproduce previous reports of configuration not working with this example: https://github.com/jdaugherty/grails7-example-configurationaware

All previous reports of this not working were due to referring to a class that no longer exists in Grails 7 due to the jakarta upgrade.

jdaugherty avatar Mar 26 '25 12:03 jdaugherty

I had the same issue. The problem was that configs get filtered by spring.profiles.active. If the config contains a spring.profiles.active property and it doesn't match your active spring profiles, or if you don't have an active spring profile the config is discarded. I didn't have an active spring profile, so I added -Dspring.profiles.active=development to the bootRun jvmArgs. This solved the issue for me.

docbee-fschrader avatar Jul 24 '25 10:07 docbee-fschrader

@weinellucian is this working in 7.0.0-RC1 or 7.0.0-SNAPSHOT?

jamesfredley avatar Aug 18 '25 22:08 jamesfredley

Environment config was broken in earlier 7 versions due to the micronaut removal. This was likely the cause given the spring profile relation.

jdaugherty avatar Aug 18 '25 22:08 jdaugherty