I can't get my custom environment to run under Tomcat. It always loads the development profile.
I create a WAR with the following under Grails 4.0.5:
grails -Dgrails.env=qa war
The resulting grails.build.info looks correct:
info.app.version=2.0.7
info.app.name=myapp
grails.env=qa
info.app.grailsVersion=4.0.5
However, when I drop it into Tomcat 8 and run, I get this:
[ost-startStop-1] com.myapp.ApplicationLoader : The following profiles are active: development
Running standalone, though, works just fine:
./gradlew -Dgrails.env=qa bootRun
grails.util.Environment, defines a number of pre-configured environments.
In
application.ymlwe get pre-configureddevelopment,test, andproductionenvironments. So if we want to add custom environments we add similarly. In your case it will beqa.With Grails command line we can execute any command within the context of a specific environment. The format is:
Suppose if want to create a WAR for the
testenvironment you wound run:To target other environments you can pass a grails.env variable to any command:
Yes, all looks good as per grails documentation and configuration.
I have Created POC app for same with
Grails 4.0.5and also downloaded external tomcatapache-tomcat-8.5.63.My
application.ymlwithqaENV:Yes. This also works fine. So, now i have created war file with
grails -Dgrails.env=qa warThen i started my tomcat and dropped mypoc-app-0.1.warfile into tomcat.when tomcat deployed/extracted my war, entered local url into browser.
You can see in above image, Environment is
qaSo 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
qaand running ondev.Also i have tested with
java -jar poc-app-0.1.warand it's running on same env as we given.Application details:
and tomcat version is
apache-tomcat-8.5.63It 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: