Shekhar Khairnar
Shekhar Khairnar

Reputation: 2691

How to set environment variables in JBoss

We are developing an application that is deployed in a JBoss. we would like to define a properties files like this:

URL_DEVELOPMENT.properties = ...
URL_TEST.properties = ...
URL_PRODUCTION.properties = ...

and define an environment variable in the JBoss which contains the information about the execution context

for example --> ENVIRONMENT = DEVELOPMENT

Anyone knows:

  1. How to set environment variables in JBoss.

  2. How to get these variables from an applicacion deployed in JBoss in runtime execution?

Upvotes: 7

Views: 26843

Answers (1)

maress
maress

Reputation: 3533

The easiest and most straight forward way is to log into jboss web admin: www.yoururl:9990

Then under configuration, look for system property.

At runtime, it is very easy: System.getProperty(yourPropertyKey) and the good thing is that a change in any of these properties is reflected immediately at runtime.

The other scenario is to open up standalone.xml

<server ...>
   <system-properties>
        <property name="eclipselink.archive.factory" value="org.jipijapa.eclipselink.JBossArchiveFactoryImpl"/>
   </system-properties>
</server>

The other option is to read on jboss cli and configure system properties from there. (Only useful if you want to work with remote jboss and you cannot ssh into the server, and you cannot access the web admin)

Upvotes: 7

Related Questions