Reputation: 9069
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.
Upvotes: 2
Views: 4761
Reputation: 2673
In case you are running Payara
(> 4.1.2.172
) server it is now possible to utilize the environment variables.
I am using excerpts from the official documentation:
<domain log-root="${com.sun.aas.instanceRoot}/${ENV=STAGE_NAME}/logs">
domain.xml
(inside attribute values or inside text nodes that contain
a configuration value)logging.properties
(inside property values)web.xml
/ glassfish-web.xml
ejb-jar.xml
/ glassfish-ejb-jar.xml
application.xml
/ glassfish-application.xml
glassfish-resources.xml
@EJB
@WebService
@Stateless
@Stateful
@Singleton
@ActivationConfigProperty
@DataSource
@WebServlet
Upvotes: 1
Reputation: 4183
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.
Upvotes: 2