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: Copy to Clipboard Toggle word wrap
      $ 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: Copy to Clipboard Toggle word wrap
      <module xmlns="urn:jboss:module:1.1" name="myorg-conf">
          <resources>
              <resource-root path="properties"/>
          </resources>
      </module>
  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:
          Copy to Clipboard Toggle word wrap
           EAP_HOME/bin/jboss-cli.sh --connect
        • For Windows, enter the following at a command line:
          Copy to Clipboard Toggle word wrap
          C:\>EAP_HOME\bin\jboss-cli.bat --connect
        You should see the following response: Copy to Clipboard Toggle word wrap
        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:
        Copy to Clipboard Toggle word wrap
        /subsystem=ee:write-attribute(name=global-modules, value=[{"name"=>"myorg-conf","slot"=>"main"}])
        You should see the following result:
        Copy to Clipboard Toggle word wrap
        {"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

        Copy to Clipboard Toggle word wrap
        <subsystem xmlns="urn:jboss:domain:ee:1.0" >            
            <global-modules>
                <module name="myorg-conf" slot="main" />            
            </global-modules>
        </subsystem>
  3. Assuming you copied a file named my.properties 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

    Copy to Clipboard Toggle word wrap
    Thread.currentThread().getContextClassLoader().getResource("my.properties");
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat, Inc.