grails.util.Environment, defines a number of pre-configured environments.
Environment APPLICATION
Environment CUSTOM
Environment DEVELOPMENT
Environment PRODUCTION
Environment TEST
In application.yml
we get pre-configured development
, test
, and production
environments. So if we want to add custom environments we add similarly. In your case it will be qa
.
With Grails command line we can execute any command within the context of a specific environment. The format is:
grails [environment] [command name]
Suppose if want to create a WAR for the test
environment you wound run:
grails test war
To target other environments you can pass a grails.env variable to any command:
grails -Dgrails.env=UAT run-app
I create a WAR with the following under Grails 4.0.5:
grails -Dgrails.env=qa war
Yes, all looks good as per grails documentation and configuration.
I have Created POC app for same with Grails 4.0.5
and also downloaded external tomcat apache-tomcat-8.5.63
.

My application.yml
with qa
ENV:

Running standalone, though, works just fine:
./gradlew -Dgrails.env=qa bootRun
Yes. This also works fine.
So, now i have created war file with grails -Dgrails.env=qa war
Then i started my tomcat and dropped my poc-app-0.1.war
file into tomcat.

when tomcat deployed/extracted my war, entered local url into browser.

You can see in above image, Environment is qa
So everything is running as i passed to env while creating war.
I tested with multiple environments, both pre-configured and custom environments. But did not got any issue like created war for qa
and running on dev
.
Also i have tested with java -jar poc-app-0.1.war
and it's running on same env as we given.
Application details:

and tomcat version is apache-tomcat-8.5.63
It may be some versions or configuration issue with your app.
Please refer this link of my poc. Can you please try to create war and deploy in same way to your tomcat and let me know.
If you are still getting issue, then please share your minimal code or poc.
Even i got one more similar kind of issue on grails repo, please do refer this.
I have followed lot of documentation and references but still not able to reproduce your issue.
Links: