0

When porting an application from the Java application server GlassFish to Wildfly I noticed that applications in Wildfly report environment variables as empty, whereas GlassFish reports a value. The application code is the same; the command to retrieve the environment variable is:

System.getenv("MY_ENV_VAR");

I'm on Linux and setting the environment variable in the .bashrc file of the user who launches GlassFish and Wildfly. I've tried adding the variable to the bin/standalone.conf, bin/standalone.sh, and the bin/.jbossclirc files of Wildfly without any success.

Here is a similar unanswered question on the JBoss Forum:

https://developer.jboss.org/thread/229862

Note: an environment variable and system property are not the same thing. A work around would be to rewrite all of my applications to use system properties instead of environment variables, but I'd like to avoid that if possible.

0

I got it working by setting the environment variables in the systemd config file as described here:

How to set environment variable in systemd service?

It seems the difference between GlassFish and Wildfly was really with the service scripts as GlassFish was using the older /etc/init.d while Wildfly was using the newer /etc/systemd.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.