Search code examples
tagsglassfishenvironment-variablesglassfish-3

How to configure the glassfish domain.xml by using the OS environment variable?


I would like to pass the environment variable to the glassfish domain.xml as the following:-

<jvm-options>-DMY_FILE=file:///${MY_HOME}/a.txt</jvm-options>

${MY_HOME} is an environment variable.

I'm not sure if this is possible or not. Could you please help to advise further? Thank you very much for your help in advance. I'm looking forward to hearing from you soon.

Regards,

Charlee Ch.


Solution

  • You can only use Java system properties (-D) to define variables outside of domain.xml.

    See Oracle GlassFish Server 3.0.1 Domain File Format Reference for details.

    If you need to change your settings regulary better you write an small wrapper script which calls asadmin to change specific parts of the configuration and starts/restarts GlassFish afterwards.