Wildfly 10.1.0 - Mysql Datasource not found

user3809736 picture user3809736 · Dec 17, 2016 · Viewed 8.7k times · Source

I know, this question is founded on all google and stackoverflow, but my problem isn't solved and I didn't find the solution =/

So, it is simple, my WildFly seems to don't see my mysql connector.

I try to use mysql-connector-java-5.1.38

module.xml (wildfly-10.1.0.Final\modules\system\layers\base\com\mysql\main)

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.mysql">
    <resources>
        <resource-root path="mysql-connector-java-5.1.38.jar"/>
    </resources>

    <dependencies>
        <modue name="javax.api"/>
    </dependencies>
</module>

Tried with and without ".jar" on mysql-connector-java-5.1.38

Datasource

<datasources>
    <datasource jndi-name="java:/budget-datasource" pool-name="budget-datasource" enabled="true" use-java-context="true" use-ccm="true">
        <connection-url>jdbc:mysql://127.0.0.1:3306/budget?zeroDateTimeBehavior=convertToNull</connection-url>
        <driver>mysql</driver>
        <security>
            <user-name>root</user-name>
        </security>
    </datasource>
    <drivers>
        <driver name="mysql" module="com.mysql">
            <xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>
        </driver>
    </drivers>
</datasources>

I tried to replace

<xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>

by

<driver>com.mysql.jdbc.Driver</driver>

but didn't work

The complete interesting stacktrace ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 33) WFLYCTL0013: Operation ("add") failed - address: ([ ("subsystem" => "datasources"), ("jdbc-driver" => "mysql")

ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "budget-datasource")
]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.mysql"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "org.wildfly.data-source.budget-datasource is missing [jboss.jdbc-driver.mysql]",
        "jboss.driver-demander.java:/budget-datasource is missing [jboss.jdbc-driver.mysql]"
    ]
}

ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "budget-datasource")
]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => [
        "jboss.jdbc-driver.mysql",
        "jboss.jdbc-driver.mysql"
    ],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "org.wildfly.data-source.budget-datasource is missing [jboss.jdbc-driver.mysql]",
        "jboss.driver-demander.java:/budget-datasource is missing [jboss.jdbc-driver.mysql]",
        "org.wildfly.data-source.budget-datasource is missing [jboss.jdbc-driver.mysql]"
    ]
}

INFO  [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184:    New missing/unsatisfied dependencies:
      service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.driver-demander.java:/budget-datasource, service org.wildfly.data-source.budget-datasource] 

I use Eclipse Mars to developp, need to configure the project to use mysql connector ?

In advance, thanks lot and lot for help, I'm so lost

I found the solution :

<modue name="javax.api"/>

<module name="javax.api"/>

Answer

Quincy picture Quincy · Dec 22, 2016

Other then creating a mysql module, try the alternative way:

1)Deploy the jar mysql-connector-java-5.1.38.jar on Wildfly

2)Set the datasource as below

 <datasources>
    <datasource jndi-name="java:/budget-datasource" pool-name="budget-datasource" enabled="true" use-java-context="true" use-ccm="true">
        <connection-url>jdbc:mysql://127.0.0.1:3306/budget?zeroDateTimeBehavior=convertToNull</connection-url>
        <driver-class>com.mysql.jdbc.Driver</driver-class>
        <driver>mysql-connector-java-5.1.38.jar</driver>
        <security>
            <user-name>root</user-name>
        </security>
    </datasource>
</datasources>