database module in jboss 7.1

The following two tabs change content below.
Prasad Kharkar is a java enthusiast and always keen to explore and learn java technologies. He is SCJP,OCPWCD, OCEJPAD and aspires to be java architect.

Latest posts by Prasad Kharkar (see all)

Hello, we are going to learn how to create a database module in jboss 7.1. Because of modular architecture for libraries in jboss 7.1, libraries need to be added as modules. We will learn how to create database module in jboss 7.1.

To configure mysql database module in jboss 7.1, we have to,

  • Create module for mysql.
  • Configure module in jboss 7.1 configuration file i.e. standalone.xml

Creating a module :

  • Under your jboss 7.1 installation, navigate to <jboss_home>/modules . For e.g. If I have installed jboss in C drive, then the location would be C:\jboss-as-7.1.1.Final\modules
  • Navigate to com directory
  • Create a folder called mysql under com .
  • Create a folder called main under mysql
  • Under mysql folder, copy your mysql_connector jar file
  • Under mysql folder, create a new file called module.xml

Your folder structure should be:


and under main folder,


Now, open  module.xml  and paste following code in it.

Save module.xml.  We are done with module creation. Now we need to tell jboss to configure this database module in jboss 7.1

Configure database module in jboss 7.1

Navigate to  <jboss_home>/standalone/configuration  and open  standalone.xml  file.

Under <datasources> , create a new  <datasource>  as follows.

jndi name is the name of datasource which you can use in the application to create database connection.

Under <subsystems> , create a new  <subsystem>  as follows

Add the driver as follows

Thus, you can create a database module in jboss 7.1 and later use it to create database connection.


Share Button

2 comments for “database module in jboss 7.1

  1. Rahul
    December 7, 2014 at 6:37 am

    Thank you so much! Works like a charm! The only thing that I faced an issue was that I already had a “subsystem” specifying the default datasource as “” (blank) which I didn’t notice. So at server startup I kept getting a “ConfigurationPersistenceException”. Fixed that to keep just this one datasource as the default one and everything worked fine. Thanks again!

Leave a Reply

Your email address will not be published. Required fields are marked *