How to refresh a custom module in JBoss EAP 6

Solution Unverified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x

Issue

  • We have created a custom module in the $JBOSS_HOME/modules directory using the module.xml below. We create a new directory under resources at runtime and it can not be found with getResource unless JBoss is restarted.
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="my.module">
    <resources>
        <resource-root path="resources"/>
    </resources>
</module>

At runtime we create a new directory under resources:

$JBOSS_HOME/modules
 - my
  - module
   - main
    - resources
     - new

Resolution

Call refreshResourceLoaders(moduleName) on the mbean: jboss.modules:type=ModuleLoader,name=LocalModuleLoader-2 for a module and it will find a new directory created under the resource root.

If there are dependant modules, relink(moduleName) needs to be called on all dependants (in transitive order if it re-exports the content)

Domain Mode Notes
The JBoss Modules MBean is not a JBoss Management API operation, it is an MBean that JBoss Modules registers in the JVM where it is running. Because of this in a JBoss EAP domain mode setup, if a module needs to be refreshed, it would have to be refreshed on each server instance via JMX.

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