Guys,
I'm facing an issue in Play 2.5 where i'm unable to access environment variable from application.conf while running in dist mode. I found this plugin au.com.onegeek-sbt-dotenv which loads environment variable (.env file) before application starts. This plugin works perfectly when running Play application in run or start mode. But when you run the dist command
activator dist
this .env file is not getting loaded since this plugin is intended for development purpose(as mentioned in their documentation). But i even tried setting environment variables manually.
Let's say application.conf looks like below:
database.uri = ${?DATABASE_URI}
and .env looks like below:
DATABASE_URI = test-db-uri
While setting environment variables manually, i'm able to send the environment variables from the command line while running application.
Ex: playapp-folder/target/universal/playapp-snapshot/bin/playapp -Ddatabase.uri = $DATABASE_URI (Working)
But without explicitly setting from command line, i'm unable to access environment variables.
Ex: playapp-folder/target/universal/playapp-snapshot/bin/playapp (Not Working)
Later i thought it could be permission issue because i referred an article which says that root user should be able to access environment variables. But it's not the case. I set environment variables in root environment and tried running as root user which doesn't make any difference.
Any idea what would be the reason for this issue? Please help me out.