Wildfly 8.0.0 mysql problems with datasource

2019-06-07 07:11发布

I've got a small problem with my standalone.xml. I made an order mysql in modules/system/layers/base/com. Inside this folder there is the folder main and inside that there is my mysql-Connector v.5.1.28 and the module.xml.

But when I run a project in Eclipse it doesn't open up the browser.If I open it in the Safari browser than the textfields are shown but the whole database entries, which should be shown up too, are missing. Instead it throws an ClassNotFoundExeption for the mysql driver. Here the snippet of my 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 jta="true" jndi-name="java:jboss/datasources/MyDB" pool-name="MyDB" enabled="true" use-java-context="true" use-ccm="true">
    <connection-url>jdbc:mysql://localhost:3306/test</connection-url>
    <driver>mysql</driver>
    <security>
      <user-name>root</user-name>
      <password>root</password>
    </security>
    <statement>
      <prepared-statement-cache-size>32</prepared-statement-cache-size>
      <share-prepared-statements>true</share-prepared-statements>
    </statement>
  </datasource>
  <drivers>
    <driver name="mysql" module="com.mysql">
      <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
    </driver>
    <driver name="h2" module="com.h2database.h2">
      <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
    </driver>
  </drivers>
</datasources>

Can anyone see the problem?

the path is modules/system/layers/base/com/mysql/main...inside is the mysql-connector-java-5.1.28-bin.jar..the module.xml:

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

<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>

    <resource-root path="mysql-connector-java-5.1.28-bin.jar"/>
</resources>
<dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
    <module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>

4条回答
不美不萌又怎样
2楼-- · 2019-06-07 07:29

There is wonderful guide here. http://wildfly.org/news/2014/02/06/GlassFish-to-WildFly-migration/

Follow this and you should be good in setting it up.

Take care of one point (blunder which I did)

While creating the module.xml on windows system see to it you save the file with proper extension. Check the type on windows explorer, it should not be a Text Document but XML Document.

To be on safer side enable the following :

Organize --> Folder and Search Option -->View Tab -->(UnCheck the option : Hide extensions for known file types)

So file you end up creating should not be modudle.xml.txt but module.xml

Regards.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-06-07 07:31

Try this configuraton:

$WILDFLY_HOME/modules/com/mysql/main/mysql-connector-java-5.1.28-bin.jar.

And in $WILDFLY_HOME/modules/com/mysql/main/module.xml:

  <?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.28-bin.jar"/>
    </resources>

    <dependencies>
      <module name="javax.api"/>
      <module name="javax.transaction.api"/>
      <module name="javax.servlet.api" optional="true"/>
    </dependencies>
  </module>

And in $WILDFLY_HOME/standalone/configuration/standalone.xml:

<drivers>
  ...
  <driver name="mysql" module="com.mysql"/>
  ...
</drivers>
查看更多
倾城 Initia
4楼-- · 2019-06-07 07:37

I also had this problem and removing this part:

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

helped me solve my problem.

查看更多
5楼-- · 2019-06-07 07:45

If people are trying to integrate this version mysql-connector-java-5.0.8 please don't waste time just use the below version. I am leaving this cause I was finding the details but could find much detail on the the version which failed work i.e. " mysql-connector-java-5.0.8"

Please download the latest version mysql-connector-java-5.1.34 it will work for the Wild fly deployment . I believe there is a defect with the earlier version of the mysql driver and they fixed the issue in the latest version. I believe it sees the compliance check which probably not loading the classes .

Check more on this url http://bugs.mysql.com/bug.php?id=62038

configuration above are right it is just that driver has the issue. please don't try and waste time just download the latest one.

查看更多
登录 后发表回答