Installing a JBoss AS 7 module using the CLI
- Published: 28 January 2013
The release 7.2 of JBoss AS introduces the capability to install a module using the Command Line Interface. In this tutorial we will show how you can install a data source as a module using a CLI script.
Modules are the heart of the new application server release. If you want to install a library as a module, in order to share with your applications, you have to create a directory structure for it and add the module.xml file descriptor and the JAR libraries. See this tutorial for more information about installing a module on your AS 7 file system.
This might be a little lenghty approach or simply it can be you don't have access to the JBoss AS file system. (e.g. a remote server installation). In order to install modules using the CLI, you have to download a JBoss AS 7.2 latest build from Jenkins https://ci.jboss.org/jenkins/job/JBoss-AS-7.x-latest/
As you can see, once you connect with the CLI (jboss-cli.cmd / jboss-cli.sh) some new commands are available, by pressing the tab key.
The command we will use is "module" and you need to provide three arguments: the module name, the resources (JAR files) and the dependencies used. Optionally you can add a module slot, in case your module uses several different implementations.
Here's the script for creating a MySQL module (line 1) + driver (line 2) + data source (line 3).
module add --name=org.mysql --resources=mysql-connector-java-5.1.18-bin.jar --dependencies=javax.api,javax.transaction.api /subsystem=datasources/jdbc-driver=mysql:add(driver-module-name=org.mysql,driver-name=mysql,driver-class-name=com.mysql.jdbc.Driver) /subsystem=datasources/data-source=MySQLDS:add(jndi-name=java:jboss/datasources/MySQLDS, driver-name=mysql, connection-url=jdbc:mysql://localhost:3306/as7development,user-name=root,password=admin)