How to install a WildFly / JBoss AS 7 module (Part 2)

User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive
 

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.

jboss as 7 configure a module

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>

Related articles available on mastertheboss.com

JBoss AS 7 introduction

This is an introduction tutorial to the newest JBoss AS 7 which a

Develop Java EE applications with JBoss AS 7

In this tutorial we will learn how to create and deploy a Java EE

Adding users with JBoss AS 7

If you are planning to add new users to your management interface

Using JBoss AS 7 management API programmatically

In this tutorial we will show how to use detyped management API t

JNDI view in JBoss AS 7

JNDI can be checked on the naming subsystem of the application se

How to install a module on WildFly / JBoss AS 7

Installing a module on WildFly / JBoss AS 7 requires creating a p

Follow us on Twitter