How to install a WildFly / JBoss AS 7 module (Part 2)
- Published: 18 November 2012
In this first tutorial we have introduced how to install a module on WildFly / JBoss AS 7. We will now some how to use an advanced feature, which allows installing different releases of a module.
Most of the modules installed in JBoss AS 7 contain just a single folder named "main" 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 implemementation of a module, all we have to do is adding the slot element, whereever 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>