How to set System properties in JBoss / WildFly ?

In this tutorial we will cover how to load System Properties from applications running on WildFly Application Server.

There are mainly three strategies to load System Properties in WildFly:

  1. Add the System Properties as JVM arguments to the start up script
  2. Include the Properties in WildFly Configuration
  3. Include the Properties in a module of the application server

Let’s see them all in detail.

Setting System Properties 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

This option is recommended in limited use cases. It is used more often as a tweak to the application server’s system properties.

Setting System Properties to 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"/>

System properties can be read/written as well using the CLI:

$ ./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 properties from a folder

If you want to load your System Properties from a folder, it is recommended 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

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=""/>

Now, 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) {

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: