How to set and load Properties in WildFly ?

In this tutorial we will cover how to load System Properties or Application Properties running on WildFly Application Server. We will also discuss how to set System Properties when running WildFly in a Kubernetes environment.

In a Bare Metal installation of WildFly, there are mainly three strategies to load Properties:

  1. Add the System Properties as JVM arguments to the start up script
  2. Include the System Properties in WildFly Configuration
  3. Include the Application Properties in a module of the application server
  4. Inject the System Properties through an environment variable (WildFly 25 or newer)

Let’s see them all in detail.

Setting System Property as JVM arguments

This is the simplest option and works as any other Java application. You can add the System Property MSG to the start up script of WildFly as follows:

$ ./ -DMSG=Hello

Next, edit the standalone.conf file and add it to the JAVA_OPTS variable:

JAVA_OPTS="$JAVA_OPTS -Dproperty=value"

Finally, in domain mode, add it as JVM Option in the host.xml file:

    <option value="-server"/>
    <option value="-XX:MetaspaceSize=96m"/>
    <option value="-XX:MaxMetaspaceSize=256m"/>
    <option value="-Dproperty=value"/>

Setting System Properties into WildFly configuration

The other option requires that you either add your system property directly into the configuration file or use the CLI. Let’s see first the configuration file approach:

  • In the Standalone mode,  the change will go into standalone.xml
  • In the Domain mode, the change will go into domain.xml
    Add the system-properties  element right after the extensions element.
  . . .

        <property name="my.project.dir" value="/home/francesco"/>

Finally, you can read/write System Properties from the CLI as follows:

$ ./bin/  
[standalone@localhost:9999 /] /system-property=foo:add(value=bar)
[standalone@localhost:9999 /] /system-property=foo:read-resource
    "outcome" => "success",
    "result" => {"value" => "bar"}

How to load Application properties from a folder

If you want to load your Applicaion Properties from a folder, we recommend to place your property file in a module and use that module in your application.

Let’s see how to do it. Place the property file (say in the “bin” folder of the application server and launch the


Execute the following command:

module add --name=configuration

Then, the following configuration will be created under the “modules” folder:

└── main
    └── module.xml

As you can see, our module named “configuration” has been defined. The file module.xml contains the list of resources available in that module:

<?xml version='1.0' encoding='UTF-8'?>

<module xmlns="urn:jboss:module:1.1" name="configuration">
        <resource-root path=""/>

Finally, if you want to use this module at application level, you can add it to your jboss-deployment-structure.xml:

         <module name="configuration" export="TRUE"/>

As an alternative, if the property file is shared between multiple applications, you can include it in the list of global modules, within your server configuration:

<subsystem xmlns="urn:jboss:domain:ee:1.0" >            
    <module name="configuration" slot="main" />            

When the Property file is available as module, to load it, you can use the following code:

    Properties props = new Properties();
        try {
   stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("");
            // Read the Properties file
        } catch (IOException e) {

Setting System Properties at application level

Next, it is worth mentioning that WildFly is able to use the META-INF/ file to set System Properties at deployment level.

Here is an example application which includes the jboss-properties file to set System Properties only for that deployment:

├── index.jsp

Therefore, if the includes the following:


Then, your index.jsp will display the property “foo”:

 out.println("foo: " + System.getProperty("foo"));

Injecting properties through environment variables

As the cloud use-cases rely often on environment variables rather than system properties, it is also possible to inject properties from environment variables as well..

Please note, is is required to use WildFly 25 or newer to use this feature.

For example, if you have the following configuration:

<file relative-to="jboss.server.log.dir" path="${log_file:server.log}"/>

Then, you can inject the value of the path element as follows:

$ export LOG_FILE=wildfly.log

$ ./

Finally, note that the System property will take precedence over the environment variable if both are defined.

Setting Properties in MicroProfile applications

If you are developing applications using MicroProfile API, we recommend checking the MicroProfile Config which allows fine-grained control over your application properties: Configuring Microservices with MicroProfile Configuration

Setting Properties in Kubernetes environment

Finally, if you are deploying your applications on OpenShift or Kubernetes, the most common option to pass properties to WildFly runtime is via Environment Properties. For example, if you are deploying WildFly using Helm Charts, then you can add them in the env section of your YAML file:

  ref: 27.0.0.Final
  contextDir: microprofile-config
  mode: bootable-jar
    value: -Pbootable-jar-openshift -Djkube.skip=true
  replicas: 1
  - name: CONFIG_PROP
    value: Hello from OpenShift

Besides, if you want to externalize the properties, for example from a ConfigMap, then you can reference the ConfigMap from your deploy section as follows:

  replicas: 1
  - configMapRef:
      name: <name-of-your-config-map>

To learn more about deploying WildFly on Kubernetes using Helm Charts check this article: WildFly on the Cloud with Helm

JBoss AS 4-5-6

One cool way to add a list of System properties to JBoss is the Properties MBean Service.
In the deployment folder look for “properties-service.xml“. (if you don’t have it in your release you can create it at any time) :

Now add your properties either in the URLList Attribute or in the Properties Attribute:

<mbean code="" 
    <attribute name="URLList">

    <attribute name="Properties">
       property1=This is the value of my property
       property2=This is the value of my other property

As you can see the The “URLList” is a comma-separated list of URL strings from which to load properties file-formatted content while the “Properties” is a specification of multiple property name=value pairs

Now you can access your properties with standard: