I've searched to see if there are any reports similar to this and there aren't, at least not that I can find. So apologies if this is answered somewhere else, but I can't dig it up if it is!
I have a bit of code where I'm checking the values of various environment variables to determine the home folder for our application (where data and configurations will be stored, mainly). The order of precedence for these settings is:
- The Java system property xnat.config.home
- The environment variable XNAT_HOME
- The environment variable HOME
is already set in the server environment, so I set the other two variables in the debug configuration (where the application is running as a web app within Tomcat 7). The first as a VM option:
The second as a an environment variable on the startup/connection tab:
Interesting! My VM option got converted to a JAVA_OPTS environment variable. That's important, as you'll see in a second.
I run my app using this configuration. When I get into the code, I can get the value for xnat.config.home
with no problem:
So the JAVA_OPTS value is getting passed along OK. The HOME environment variable also resolves:
XNAT_HOME does not:
In practice, this won't be a problem: XNAT_HOME will be set in the environment in pretty much the same way that the HOME value is set, so it will get picked up in the same way. But it does make testing this in development difficult. I'm reasonably certain that the problem is that the Tomcat process is being forked and connected, so that the forked process isn't operating in the same environment space, but that would make any environment configuration prior to the fork completely useless.
Is there some magic I need to do to get my environment variables available to applications within a server container?
This is with IntelliJ IDEA 14.1.5 on OS X 10.10.5.
Thanks for any help!