1

We are needing to set a system variable that our application can read that is being ran within Glassfish 4. The application is currently accessing the system variable with System.getenv().

We set an a system environment property in Windows like this:

App_Home=/opt/app/config

I have tried adding it to glassfish/glassfish4/config/asenv.conf but that didn't seem to work. I have done a bunch of searching and everything I keep running back into is setting a java property (e.g. this How to set an env variable in Glassfish 2.1). I am wanting to access the system property not a java property.

I have also tried setting the "System Properties" in the glassfish administration console under "Server (Admin Server) --> Properties --> System Properties" clicked "Add Property" and added my environment variable. However, the application still doesn't find it using System.getenv().

Kevin Vasko
  • 1,561
  • 3
  • 22
  • 45
  • maybe this helps you: https://stackoverflow.com/questions/29782467/system-getenv-returns-null-when-the-environment-variable-exists – Tobi Tiggers Sep 04 '17 at 11:32
  • I appreciate it but what I ended up doing was using the service "Environment" value in my glassfish.service file. – Kevin Vasko Sep 05 '17 at 18:10

1 Answers1

0

I was able to use Service Environment= option in my services file to resolve this.

Simply adding the following worked:

Environment="App_Home=..."
Environment="PYTHONPATH=..."
Kevin Vasko
  • 1,561
  • 3
  • 22
  • 45