Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wildfly MySQL datasource: service jboss.jdbc-driver.mysql (missing) dependents

I'm using Wildfly 10. At first I tried to create datasource via CLI.

A command deploy mysql-connector-java-6.0.4.jar was executed well. /subsystem=datasources:installed-drivers-list shows that driver was installed

{
    "driver-name" => "mysql-connector-java-6.0.4.jar",
    "deployment-name" => "mysql-connector-java-6.0.4.jar",
    "driver-module-name" => undefined,
    "module-slot" => undefined,
    "driver-datasource-class-name" => undefined,
    "driver-xa-datasource-class-name" => undefined,
    "driver-class-name" => "com.mysql.cj.jdbc.Driver",
    "driver-major-version" => 6,
    "driver-minor-version" => 0,
    "jdbc-compliant" => false
}

But data source was not created with command

data-source add --name=zktest-datasource
--jndi-name=java:/jdbc/zktest-database --driver-name=mysql-connector-java-6.0.4.jar --connection-url=jdbc:mysql://localhost:3306/zktest --user-name=root --password=111

Connection test

/subsystem=datasources/data-source=zktest-datasource:test-connection-in-pool
was failed.

Now I trying to create datasource using standalone.xml

My modules.xml

<module xmlns="urn:jboss:module:1.1" name="com.mysql.jdbc">
  <resources>
    <resource-root path="mysql-connector-java-6.0.4.jar">
  </resource-root>
  </resources>
  <dependencies>
    <module name="javax.api"></module>
    <module name="javax.transaction.api"></module>
  </dependencies>
</module>

modules.xml placed into the JBOSS_HOME/modules/system/layers/base/com/mysql/jdbc

'Datasources' section in JBOSS_HOME/standalone/configuration/standalone.xml

<datasources>
        <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
            <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
            <driver>h2</driver>
            <security>
                <user-name>sa</user-name>
                <password>sa</password>
            </security>
        </datasource>
        <datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS" enabled="true" use-java-context="true">
            <connection-url>jdbc:mysql://localhost:3306/zktest</connection-url>
            <driver>mysql</driver>
            <security>
                <user-name>root</user-name>
                <password>111</password>
            </security>
        </datasource>
        <drivers>
            <driver name="h2" module="com.h2database.h2">
                <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
            </driver>
            <driver name="mysql" module="com.mysql.jdbc">
                <xa-datasource-class>com.mysql.cj.jdbc.Driver</xa-datasource-class>
            </driver>
        </drivers>
    </datasources> 

Now while deploing I see such message

WFLYCTL0184: New missing/unsatisfied dependencies: service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.driver-demander.java:jboss/datasources/MySqlDS, service org.wildfly.data-source.MySqlDS]

And while test connection in Wildfly control panel:

{ "outcome" => "failed", "failure-description" => "WFLYJCA0040: failed to invoke operation: WFLYJCA0042: failed to match pool. Check JndiName: java:jboss/datasources/MySqlDS", "rolled-back" => true }

like image 792
evgeny_s Avatar asked Oct 09 '16 21:10

evgeny_s


2 Answers

Problem was solved by changing driver to mysql-connector-java-5.1.38.jar. I removed the old driver, and then performed the following steps in the CLI:

module add --name=com.mysql.jdbc --resources=mysql-connector-java-5.1.38.jar --dependencies=javax.api,javax.transaction.api

/subsystem=datasources/jdbc-driver=mysql:add(driver-name="mysql",driver-module-name="com.mysql.jdbc",driver-class-name=com.mysql.jdbc.Driver)

data-source add --name=MySQLDS --driver-name=mysql --connection-url=jdbc:mysql://localhost:3306/zktest --jndi-name=java:jboss/jdbc/MySQLDS --user-name=username --password=password

data-source enable --name=MySQLDS
like image 194
evgeny_s Avatar answered Sep 17 '22 17:09

evgeny_s


My problem was that I was uploading the wrong jar.

I had to download another jar from MySQL website

The name of the right jar is mysql-connector-java-5.1.40-bin.jar pay attention to -bin

It solved the problem.

like image 30
Vitaly Olegovitch Avatar answered Sep 21 '22 17:09

Vitaly Olegovitch