JBoss – initial setup and datasource configuration

There are two versions of JBoss: AS (Application Server) and EAP (Enterprise Application Platform). You can read more about the differences here.

I will use EAP 6.3.0 and Java 1.8 for this setup. Download and unzip. In my case in c:\jboss-eap-6.3

The first thing you need to do is to add an user, so from elevated prompt run
C:\jboss-eap-6.3\bin\add-user.bat and after creating the account run
C:\jboss-eap-6.3\bin\standalone.bat If you get any port conflicts, please follow the instructions here. As the name of the file suggests, JBoss will run in Standalone mode.

Let’s add a datasource to the configuration. Since there are no built-in MySQL drivers, we need to download them.
Create a new module.xml with the following:

<module xmlns="urn:jboss:module:1.0" name="com.mysql">
     <resource-root path="mysql-connector-java-5.1.34-bin.jar"/>
      <module name="javax.api"/>
      <module name="javax.transaction.api"/>

Copy the module.xml and the JAR file to the modules folder in your EAP installation, and follow the file structure:

¦ +---mysql
¦ ¦ +---main
¦ ¦ +-------module.xml
¦ ¦ +-------mysql-connector-java-5.1.34-bin.jar

After this, we need to fund the section in C:\jboss-eap-6.3\standalone\configuration\standalone.xml
and add the newly installed driver:

                    <driver name="h2" module="com.h2database.h2">
                    <driver name="mysql" module="com.mysql"/>

This will install the MySQL drivers for JBoss. Now that we have those set, we just add the datasource. In my case a “test” database.

There are few important default ports:
http://localhost:8080 – The default JBoss HTTP Port and
http://localhost:9990 – The admin console

Go to http://localhost:9990/console/App.html#datasources

Add the new datasource

Name it

You can see the driver that we installed here

Add the connection URL jdbc:mysql://localhost:3306/mydb and the DB credentials

And test the connection

  1 comment for “JBoss – initial setup and datasource configuration

  1. May 19, 2016 at 19:11

    Thank you very much, I have had problems with datasources before, and after I follow your tutorial, it’s work fine.
    I always use glassfish server before, and quite new in jboss, so, your article is very helpful. thx.

Leave a Reply

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