0
votes

I'm trying to add a new MySQL datasource with the JBoss (7.1.1) wizard. I have this structure:

$JBOSS_DIR
|-- modules
    |-- com
        |-- mysql
            |-- main
                |-- module.xml
                |-- mysql-connector-java-5.1.37-bin.jar

Content of $JBOSS_DIR/modules/com/mysql/main/module.xml:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="mysql">
    <resources>
        <resource-root path="mysql-connector-java-5.1.37-bin.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

I added this line in $JBOSS_DIR/standalone/configuration/standalone.xml under datasources/drivers tags:

<driver name="mysql" module="com.mysql">

With the information that I found, this configuration would be enough to add the MySQL driver.

To try this, first I start the server (without error messages) and I access the Add Datasource wizard. In the first step, I use this parameters:

Add Datasource Wizard Step 1

But when I click 'Next' to go to the second step, I get this:

Add Datasource Wizard Step 2

As you can see I only have the default JBoss Driver (h2) but the MySQL one doesn't appear.

Any idea about what is happening?

Regards.

1

1 Answers

0
votes

I found a solution making a little change on the settings above.

In the module.xml file, the module's name is wrong; it have to be a package format following the path where it is stored. So, in this case, as the module is stored in /modules/com/mysql, the name must be com.mysql, so the file content would be:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
    <resources>
        <resource-root path="mysql-connector-java-5.1.37-bin.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

In the standalone.xml file, we should add a 'driver-class' tag within the 'driver' tag, like this:

<driver name="mysql" module="com.mysql">
    <driver-class>com.mysql.jdbc.Driver</driver-class>
</driver>

Once this is done, I started the server and when I arrived to the second step again, I saw this:

Step 2 with MySQL Driver

Regards ;)