Wildfly 11 does not recognize Mysql driver when deploying

Asked

Viewed 550 times

2

I set up my Java Web project to use JTA when performing transactions with the Database. My project has 4 Maven modules, one is unique to model classes and the persistence layer. When I compile in Maven the result is success, but when trying to upload the application in Wildfly, it overflows the problem under 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 is 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>

Inside 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 going on? Thank you!

  • you can give more details ?

  • Hello, friend! My project is divided into 4 modules. In just one I configured JPA with persistence.xml, which is the module with the model classes and Daos. When I run Maven, it builds successfully, but when trying to run the application that error happens there above. What kind of more information can I pass on, friend? Thanks for the force!

  • more in your IDE works ?

  • I am using Netbeans and it only works with Maven. When I try to run by Netbeans itself, the error occurs.

1 answer

1


Hey there, guys! 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 file standalone-full.xml goes below:

<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 is occurring another cast problem of Wildfly 11 with Dom4j, but as I believe that has nothing to do with this, I decided to open another question in this link below:

Wildfly 11 cast error with Dom4j

Thank you to everyone who tried to help!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.