3 Replies Latest reply on Nov 24, 2015 5:31 PM by George Berish

    Why does this normal MySql datasource set up fail?

    George Berish Novice

      According to everything I read, it should be a trivial exercise to add a Mysql database as a datasource:


      1. Get the driver jar (mysql-connector-java-5.1.35.jar).


      2. Put it in ${WILDFLY_HOME}\modules\system\layers\base\com\mysql\driver\main


      3. Add module.xml to the same directory.

      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.3" name="com.mysql.driver">

        <resources>

          <resource-root path="mysql-connector-java-5.1.35.jar" />

        </resources>

        <dependencies>

          <module name="javax.api"/>

          <module name="javax.transaction.api"/>

        </dependencies>

      </module>


      4. Run the following command:

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

       

      But for me it just doesn't work. 

      Can anyone tell me what I'm doing wrong?

      I know that 99% of the time it is a typo.  And I'm braced for being hugely embarrassed if there is one, but I just can't see it.

       

      I've found one other answer, but I'm not sure how to use it.  Does this seem a likely problem?  I'm not really sure how to implement it.

      "In my case it was a matter of having the wrong user:group for the directories and files under ../com/mysql/main

      I changed it to wildlfy and everything worked as expected."

       

      Here is the output from command line of my last failure: 

      I started WildFly using standalone-full.xml.

       

      Microsoft Windows [Version 6.1.7601]

      Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

      ...

       

      D:\Bulletproof\bpWildFly\bin>jboss-cli.bat

      You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.

      [disconnected /] connect

       

      [standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql.dri

      ver,driver-class-name=com.mysql.jdbc.Driver)

      {

          "outcome" => "failed",

          "failure-description" => "WFLYJCA0041: Failed to load module for driver [com.mysql.driver]",

          "rolled-back" => true

      }

      [standalone@localhost:9990 /]

        • 1. Re: Why does this normal MySql datasource set up fail?
          Jay SenSharma Master

          Try creating the Module itself using the   jboss-cli.sh command rather than manually writing the module.xml file. This is because when we use some text editors, they might append some hidden chars to our files. (Specially when we do a copy & paste in such editors)

           

          [standalone@localhost:9990 /]  module add --name=com.mysql.driver  --dependencies=javax.api,javax.transaction.api --resources=/PATH/TO/mysql-connector-java-5.1.35.jar
          
          [standalone@localhost:9990 /] :reload
          {
              "outcome" => "success",
              "result" => undefined
          }
          
          
          

          After running above command you should see the module.xml generated in the following location:  "wildfly-8.2.1.Final/modules/com/mysql/driver/main/module.xml"

          Now create DataSource:

           

          [standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=mysql/:add(driver-module-name=com.mysql.driver,driver-name=mysql,jdbc-compliant=false,driver-class-name=com.mysql.jdbc.Driver)
          {"outcome" => "success"}
          
          
          

           

           

          Regards

          Jay SenSharma

          • 2. Re: Why does this normal MySql datasource set up fail?
            Wolfgang Mayer Master

            George, l understand WildFly is checking against the jar file for searching the driver when using your approach. So you could also try to change your path to  ${WILDFLY_HOME}/modules/system/layers/base/com/mysql/main/ instead.

            • 3. Re: Why does this normal MySql datasource set up fail?
              George Berish Novice

              Jay,

              Once again your solution was correct on the first try.

               

              To anyone who follows, using jboss-cl seems like a good advice. 

              However, in my case I'm not sure if that was the most important cause of failure.

               

              What I think was causing my problem was a disconnect between the values set in module.xml, and where I stored it.

               

              I was likely reading the same advice offered in another comment below, because I was storing module.xml and the driver jar in "wildfly-8.2.1.Final/modules/system/layers/base/com/mysql/driver/main".

               

              When I stored them in "wildfly-8.2.1.Final/modules/com/mysql/driver/main/ instead, it worked perfectly.

              1 of 1 people found this helpful