Unable to add MySQL data source to WildFly

I’m having some trouble adding a MySQL data source to WildFly. I’ve installed (perhaps incorrectly?) the MySQL driver as shown below:

MySQL driver as shown in WildFly

Then, when I go to add the data source, MySQL is missing from the list of available driver names:

MySQL driver is missing when trying to add datasource

I suspect I must have installed the driver incorrectly as the driver version is missing from my first screenshot, and nothing is shown under JDBC compliant. Not sure if this is normal.

I have followed a number of guides to install the driver, and this is how I have done it. I downloaded the driver from https://dev.mysql.com/downloads/connector/j/. The driver is located in the following file path:


and this is what that folder structure looks like:

mysql main folder structure

This is the contents of module.xml:

<module name="com.mysql" xmlns="urn:jboss:module:1.5">
        <resource-root path="mysql-connector-java-8.0.23.jar">
        <module name="javax.api">
        <module name="javax.transaction.api">

This is what the relevant driver section in standalone.xml looks like (including the h2 and derby-main drivers which seem to work fine):

   <driver name="h2" module="com.h2database.h2">
   <driver name="derby-mem" module="org.apache.derby.mem"/>
   <driver name="mysql" module="com.mysql">

I must be missing something obvious here.


I would strongly recommend using a script for this instead of the UI. It is easier to maintain and upgrade.

Create a file called something like create_resources.cli that contains:

embed-server --server-config=standalone.xml --std-out=echo

# add the module
module add --name=com.mysql --resources=${user.home}/Downloads/mysql-connector-java-8.0.23/mysql-connector-java-8.0.23.jar --dependencies=javax.api,javax.transaction.api

# create the driver

# create the datasource


Now, with Wildfly stopped, change to the Wildfly installation directory and run

binjboss-cli.bat --file=create_resources.cli

This will do the following:

  1. Add the module for you. I have the driver in the Downloads directory in your home directory. Obviously it can be wherever you’d like.
  2. Add a driver named “mysql”
  3. Add a datasource named “YourDSName”.

The advantage of this is that you don’t need to run the UI to add the datasource. Additionally, I am constantly changing my Wildfly installation version and what is installed in a particular one. This way you can regenerate the changes very quickly.

Leave a Reply

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