Red Hat Training

A Red Hat training course is available for Red Hat JBoss Enterprise Application Platform

7.4. Create a Custom Module

The following procedure describes how to create a custom module in order to make properties files and other resources available to all applications running on the JBoss EAP server.

Procedure 7.2. Create a Custom Module

  1. Create and populate the module/ directory structure.
    1. Create a directory structure under the EAP_HOME/module directory to contain the files and JARs. For example:
      $ cd EAP_HOME/modules/ 
      $ mkdir -p myorg-conf/main/properties
    2. Move the properties files to the EAP_HOME/modules/myorg-conf/main/properties/ directory you created in the previous step.
    3. Create a module.xml file in the EAP_HOME/modules/myorg-conf/main/ directory containing the following XML:
      <module xmlns="urn:jboss:module:1.1" name="myorg-conf">
              <resource-root path="properties"/>
  2. Modify the ee subsystem in the server configuration file. You can use the Managemet CLI or you can manually edit the file.
    • Follow these steps to modify the server configuration file using the Management CLI.
      1. Start the server and connect to the Management CLI.
        • For Linux, enter the following at the command line:
           EAP_HOME/bin/ --connect
        • For Windows, enter the following at a command line:
          C:\>EAP_HOME\bin\jboss-cli.bat --connect
        You should see the following response:
        Connected to standalone controller at localhost:9999
      2. To create the myorg-conf <global-modules> element in the ee subsystem, type the following in the command line:
        /subsystem=ee:write-attribute(name=global-modules, value=[{"name"=>"myorg-conf","slot"=>"main"}])
        You should see the following result:
        {"outcome" => "success"}
    • Follow these steps if you prefer to manually edit the server configuration file.
      1. Stop the server and open the server configuration file in a text editor. If you are running a standalone server, this is the EAP_HOME/standalone/configuration/standalone.xml file, or the EAP_HOME/domain/configuration/domain.xml file if you are running a managed domain.
      2. Find the ee subsystem and add the global module for myorg-conf. The following is an example of the ee subsystem element, modified to include the myorg-conf element:

        Example 7.3. myorg-conf element

        <subsystem xmlns="urn:jboss:domain:ee:1.0" >            
                <module name="myorg-conf" slot="main" />            
  3. Assuming you copied a file named into the correct module location, you are now able to load properties files using code similar to the following:

    Example 7.4. Load properties file