Configuring module slots in WildFly
This article covers modules slot installation which allows having multiple versions from the same module, grouped in slots.
Before getting started, we recommend that you check the following resources available on this site:
Most of the modules installed in WildFy contain just a single “main” folder under the modules path. For example, Hibernate module name is “org.hibernate” and libraries are contained in the “org.hibernate.main” folder. The main folder is by convention the default library folder which is used for the module, if you do not specify a module slot.
A module slot is just another folder, at the same level of the main folder, where you can place additional modules implementations. For example, supposing that we want to have installed three different driver versions for mySQL driver. So let’s create one (default) main folder and two additional slots named with the JDBC version we want to install.

Then, inside each folder we will place the module.xml declaration and the JDBC driver. for example in the folder “5.21” we will configure the JDBC driver as follows:
<module xmlns="urn:jboss:module:1.0" name="com.mysql" slot="5.21">
<resources>
<resource-root path="mysql-connector-java-5.1.21-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
The folder 5.20 needs to be adjusted accordingly with the correct “slot” and the JDBC driver.
On the other hand, the “main” folder will contain just the module name specification, since it is meant to be the default module implementation:
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.18-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
How to use a module slot
In order to use a non-default implementation of a module, all we have to do is adding the slot element, wherever the module is specified. For example, in the datasource configuration, the module name is specified into the drivers stanza:
<drivers>
<driver name="mysql" module="com.mysql" slot="5.21"/>
</drivers>
Recommended Articles
Install WildFly Module Using Command Line Interface: A Step-by-Step Guide
Learn how to install a module on WildFly / JBoss EAP using the CLI for efficient and secure application server management.
WildFly: Simplify Module Management with Global Directories and Modules
Effortlessly share modules across Enterprise Applications with WildFly's global directories and modules feature. Learn how to configure them now!
Step-by-Step Guide: Architecting the Fix for WFLYJCA0041: Failed to load module for driver
Resolve WFLYJCA0041: Failed to load module for driver in WildFly. A hands-on guide for developers to debug JBoss module configurations, paths, and XML syntax.
Configure Multiple HTTP Ports on WildFly Application Server for Enhanced Security and Scalability
Learn how to configure multiple HTTP ports on WildFly, restrict them to specific applications, and secure your Java-based infrastructure. #WildFly #Java #Middleware #CloudNative