WildFly 11 does not recognize MySQL driver when deploying

2

I set up my Java Web project to use JTA when transacting with the Database. My project has 4 Maven modules, one is unique to the model classes and to the persistence layer. When I compile in Maven the result is success, but when trying to upload the application in WildFly, it pops up the problem below the MySQL driver configuration:

    Deploying on WildFly Application Server
    profile mode: false
    debug mode: true
    force redeploy: true
Iniciando WildFly Application Server
WildFly Application Server iniciado
Implantação inicial de for_clinic-web até /usr/local/WildFly/wildfly-11.0.0.Final/standalone/deployments/for_clinic-web-1.0.0-SNAPSHOT.war
Distribuição inicial do for_clinic-web completada
Implantando /usr/local/WildFly/wildfly-11.0.0.Final/standalone/deployments/for_clinic-web-1.0.0-SNAPSHOT.war
{"WFLYCTL0288: One or more services were unable to start due to one or more indirect dependencies not being available." => {
"Services that were unable to start:" => [
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".CdiValidatorFactoryService",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".WeldStartService",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"com.sun.faces.config.ConfigureListener\".START",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"com.sun.faces.config.ConfigureListener\".WeldInstantiator",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"javax.faces.webapp.FacesServlet\".START",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"javax.faces.webapp.FacesServlet\".WeldInstantiator",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"javax.faces.webapp.FacetTag\".START",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"javax.faces.webapp.FacetTag\".WeldInstantiator",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV\".START",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV\".WeldInstantiator",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"javax.servlet.jsp.jstl.tlv.ScriptFreeTLV\".START",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"javax.servlet.jsp.jstl.tlv.ScriptFreeTLV\".WeldInstantiator",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"org.jboss.weld.servlet.WeldInitialListener\".START",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"org.jboss.weld.servlet.WeldInitialListener\".WeldInstantiator",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"org.jboss.weld.servlet.WeldTerminalListener\".START",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.\"org.jboss.weld.servlet.WeldTerminalListener\".WeldInstantiator",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.pacienteBusiness.START",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.pacienteBusiness.WeldInstantiator",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.pacienteBusiness.WeldInterceptorBindingsService",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.pacienteDAO.START",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.pacienteDAO.WeldInstantiator",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.pacienteDAO.WeldInterceptorBindingsService",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.pacienteService.START",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.pacienteService.WeldInstantiator",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.pacienteService.WeldInterceptorBindingsService",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.usuarioDAO.START",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.usuarioDAO.WeldInstantiator",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.usuarioDAO.WeldInterceptorBindingsService",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.usuarioService.START",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.usuarioService.WeldInstantiator",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".component.usuarioService.WeldInterceptorBindingsService",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".deploymentCompleteService",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".jndiDependencyService",
    "jboss.deployment.unit.\"for_clinic-web-1.0.0-SNAPSHOT.war\".moduleDeploymentRuntimeInformationStart",
    "jboss.naming.context.java.module.\"for_clinic-web-1.0.0-SNAPSHOT\".\"for_clinic-web-1.0.0-SNAPSHOT\".env.\"br.com.for_systems.for_clinic_domain.persistence.dao.GenericDAO\".entityManager",
    "jboss.persistenceunit.\"for_clinic-web-1.0.0-SNAPSHOT.war#FOR_Clinic-PU\"",
    "jboss.persistenceunit.\"for_clinic-web-1.0.0-SNAPSHOT.war#FOR_Clinic-PU\".__FIRST_PHASE__",
    "jboss.undertow.deployment.default-server.default-host./for_clinic",
    "jboss.undertow.deployment.default-server.default-host./for_clinic.UndertowDeploymentInfoService"
],
"Services that may be the cause:" => ["jboss.jdbc-driver.mysql"]

My persistence.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="FOR_Clinic-PU" transaction-type="JTA">
    <description>JPA-Hibernate Configuração</description>
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <jta-data-source>java:/jboss/datasources/for_clinic_DS</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
        <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
        <property name="hibernate.show_sql" value="true"/>
        <property name="hibernate.format_sql" value="true"/>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
        <property name="hibernate.connection.charSet" value="UTF-8"/>
    </properties>
  </persistence-unit>
</persistence>

And here's the configuration of my DataSource in WildFly:

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

In the WildFly directory, I configured and added the MySQL driver in the following path (modules / system / layers / base / com / mysql / main) and added the module.xml below:

<?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.45-bin.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
        <module name="javax.servlet.api" optional="true"/>
    </dependencies>
</module>

Does anyone have any idea what might be happening? Thanks!

    
asked by anonymous 09.02.2018 / 03:07

1 answer

1

Hello everyone! I found the cause of this problem. I deleted my DataSource in the WildFly configuration file and left only the driver to see the result. Then the console pointed out that I was using a deprecated package from the MySQL driver. The right package to use is this: com.mysql.cj.jdbc.Driver

Then the correct DataSource and Driver configuration in the standalone-full.xml file follows:

<datasource jta="true" jndi-name="java:jboss/datasources/for_clinic_mysql_DS" pool-name="for_clinic_mysql_DS" enabled="true" use-ccm="false">
                <connection-url>jdbc:mysql://127.0.0.1:3306/for_clinic?zeroDateTimeBehavior=convertToNull</connection-url>
                <driver-class>com.mysql.cj.jdbc.Driver</driver-class>
                <driver>mysql</driver>
                <security>
                    <user-name>root</user-name>
                    <password>310990</password>
                </security>
                <validation>
                    <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
                    <background-validation>true</background-validation>
                    <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
                </validation>
            </datasource>
            <drivers>
                <driver name="mysql" module="com.mysql">
                    <driver-class>com.mysql.cj.jdbc.Driver</driver-class>
                </driver>
            </drivers>

Now there is another casting problem of WildFly 11 with Dom4J, but as I believe it has nothing to do with this, I decided to open another question in this link below:

WildFly 11 cast error with Dom4J

Thanks to everyone who tried to help!

    
12.02.2018 / 19:04