Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

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.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Beginner
Duration
Clock icon 15m
Published
Clock icon Jan 24, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Download Module Drivers

    1. Download the MySQL JDBC connector:

      wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.18.tar.gz
      
    2. Extract the contents:

      tar xf mysql-connector-java-8.0.18.tar.gz
      
  2. Challenge

    Create Module

    1. Move into the modules directory:

      cd /opt/jboss-eap/modules
      
    2. Create com directory to store local, non-system modules:

      sudo mkdir com
      
    3. We can now create the mysql module directory underneath this; each module stores all required configurations and JAR files in a required main directory, so create this, too:

      sudo mkdir -p com/mysql/main
      
    4. 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/
      
  3. Challenge

    Create .xml File

    Within the main directory for the mysql module, create a module.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 be com.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/.

  4. Challenge

    Add as a Global Module

    1. Open the management CLI:

      cd ..
      sudo ./bin/jboss-cli.sh
      
    2. Connect:

      connect
      
    3. Add the module to global modules, under the EE subsystem:

      /subsystem=ee:list-add(name=global-modules,value={name=com.mysql})
      
    4. We can check that the module has been added by logging in to the Management Console at PUBLICIP:9990 using the username admin and the password pinehead. Select Start, under Configuration, then select Subsystems from the menu. View the EE subsystem. Select Global Modules -- the com.mysql module should be listed.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

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.

Start learning by doing today

View Plans