Global modules in JBoss EAP

Solution Verified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform (JBoss EAP)
    • 7
    • 6

Issue

  • What are global modules and how are they configured

Resolution

From the documentation on JBoss EAP 7 - Chapter 6: Add Global Module:

A global module is a module that JBoss EAP provides as a dependency to every application. Any module can be made global by adding it to JBoss EAP’s list of global modules, so it does not require changes to the module.

Assuming there is already a static module under $JBOSS_HOME/modules 1.

  1. One can set this module (or a list of modules) as global modules via this CLI:

        /subsystem=ee:write-attribute(name=global-modules,value=[{name=MODULE_NAME_1},{name=MODULE_NAME_2}]
    

    Prefix this with /profile=PROFILENAME in domain mode

  2. Add a module to the list with this CLI:

        /subsystem=ee:list-add(name=global-modules,value={name=MODULE_NAME})
    

    Prefix this with /profile=PROFILENAME in domain mode

As consequence, the XML in standalone.xml or domain.xml look like this:

        <subsystem xmlns="urn:jboss:domain:ee:4.0" >
            <global-modules>
                <module name="org.javassist" slot="main" />
                <module name="MODULE_NAME_1" slot="main" />
                <module name="MODULE_NAME_2" slot="main" />
            </global-modules> 
        </subsystem>

Make the services configured in the global module accessible by external dependencies

To make the global module accessible by external dependencies is necessary, there are two way to do so:
1. Add services="import" to the module in the jboss-deployment-structure.xml
2. Add services="true" to the global module definition.

The configuration file (domain.xml or standalone.xml) does not accept export option and only accepts services as boolean (true or false).


  1. If this assumption is fulfilled, so then module add --name=com.example.web --resources=placeholder\target\placeholder.jar should return Module com.example.web already exists at /placeholder/target/jboss-eap-7.2/modules/com/example/web/main/example.jar ↩︎

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments