- Lab
- A Cloud Guru
Adding a Module to JBoss EAP
The JBoss Enterprise Application Platform provides extensive support for deploying and managing Java-based applications. Part of this support includes the ability to add and create modules, which in turn opens up additional functionality for your application — such as allowing the option to connect to a MySQL database, as in this lab.
Path Info
Table of Contents
-
Challenge
Download Module Drivers
-
Download the MySQL JDBC connector:
wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.18.tar.gz
-
Extract the contents:
tar xf mysql-connector-java-8.0.18.tar.gz
-
-
Challenge
Create Module
-
Move into the
modules
directory:cd /opt/jboss-eap/modules
-
Create
com
directory to store local, non-system modules:sudo mkdir com
-
We can now create the
mysql
module directory underneath this; each module stores all required configurations andJAR
files in a requiredmain
directory, so create this, too:sudo mkdir -p com/mysql/main
-
Move the downloaded
.jar
file into this new directory:sudo mv ~/mysql-connector-java-8.0.18/mysql-connector-java-8.0.18.jar com/mysql/main/
-
-
Challenge
Create .xml File
Within the
main
directory for themysql
module, create amodule.xml
file to configure the MySQL JDBC diver. Note that the name of the module must mimic the directory structure — in this case, it should becom.mysql
:sudo vim com/mysql/main/module.xml <?xml version="1.0" ?> <module xmlns="urn:jboss:module:1.1" name="com.mysql"> <resources> <resource-root path="mysql-connector-java-8.0.18.jar"/> </resources> <dependencies> <module name="javax.api"/> <module name="javax.transaction.api"/> </dependencies> </module>
Note that the dependencies provided are system modules, found in
/opt/jboss-eap/modules/system/layers/base/javax/
. -
Challenge
Add as a Global Module
-
Open the management CLI:
cd .. sudo ./bin/jboss-cli.sh
-
Connect:
connect
-
Add the module to global modules, under the EE subsystem:
/subsystem=ee:list-add(name=global-modules,value={name=com.mysql})
-
We can check that the module has been added by logging in to the Management Console at
PUBLICIP:9990
using the usernameadmin
and the passwordpinehead
. Select Start, under Configuration, then select Subsystems from the menu. View the EE subsystem. Select Global Modules -- thecom.mysql
module should be listed.
-
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.