Show Table of Contents
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
- Create and populate the
module/directory structure.- Create a directory structure under the
EAP_HOME/moduledirectory to contain the files and JARs. For example:$ cd EAP_HOME/modules/$ mkdir -p myorg-conf/main/properties - Move the properties files to the
EAP_HOME/modules/myorg-conf/main/properties/directory you created in the previous step. - Create a
module.xmlfile in theEAP_HOME/modules/myorg-conf/main/directory containing the following XML:<module xmlns="urn:jboss:module:1.1" name="myorg-conf"> <resources> <resource-root path="properties"/> </resources> </module>
- Modify the
eesubsystem 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.
- Start the server and connect to the Management CLI.
- For Linux, enter the following at the command line:
EAP_HOME/bin/jboss-cli.sh --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
- To create the
myorg-conf<global-modules> element in theeesubsystem, 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.
- 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.xmlfile, or theEAP_HOME/domain/configuration/domain.xmlfile if you are running a managed domain. - Find the
eesubsystem and add the global module formyorg-conf. The following is an example of theeesubsystem element, modified to include themyorg-confelement:Example 7.3.
myorg-confelement<subsystem xmlns="urn:jboss:domain:ee:1.0" > <global-modules> <module name="myorg-conf" slot="main" /> </global-modules> </subsystem>
- Assuming you copied a file named
my.propertiesinto the correct module location, you are now able to load properties files using code similar to the following:Example 7.4. Load properties file
Thread.currentThread().getContextClassLoader().getResource("my.properties");

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.