this.jind
this.jind

Reputation: 349

Error while running project on Wildfly-datasource DB connection

I'm trying to connect my project to a Database(with Mysql workbench). I have two files: persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2" 
    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_2.xsd">
    
    <persistence-unit name="dogs-breeds-jee" transaction-type="JTA">
    
    <jta-data-source>java:jboss/datasources/dogsBreedsEeDS</jta-data-source>
    
    <class>domain.Breed</class>
    
    <exclude-unlisten-classes>true</exclude-unlisten-classes>
    
    <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL8Dialect"/>
        <property name="hibernate.hbm2ddl.auto" value="create"/>
        <property name="hibernate.show_sql" value="true"/>
        <property name="hibernate.format_sql" value="true"/>
        <property name="hibernate.use_sql_comments" value="true"/>
        <property name="hibernate.default_batch_fetch_size" value="16"/>
        <property name="hibernate.jdbc.batch_size" value="100"/>
        <property name="hibernate.order_updates" value="true"/>
        <property name="hibernate.id.new_generator_mappings" value="true"/>
    </properties>
    </persistence-unit>
</persistence>

and an .xml for my datasource:

<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns ="http://www.jboss.org/ironjacamar/schema"
            xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation ="
            http://www.jboss.org/ironjacamar/schema
            http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
            <datasource jndi-name="java:jboss/datasources/dogsBreedsEeDS" enabled="true" use-java-context ="true" pool-name="dogsBreedsEeDS">
            <connection-url> jdbc:mysql://localhost:3306/java-ee-schema?serverTimezone=UTC</connection-url>
            <driver> com.mysql.jdbc.Driver </driver>
            <security>
                <user-name> java--client </user-name>
                <password> password </password> 
            </security>
            </datasource>
</datasources>

I've done the mapping in my model and if everything is okay it should create a db in my java-ee-schema right?

but I'm getting these errors when I run my WildFly server:

658 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 44) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("jdbc-driver" => "mysql")
]) - failure description: "WFLYJCA0041: Failed to load module for driver [com.mysql]"

799 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "dogs-breeds-jee-ds.xml")]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.com_mysql_jdbc_Driver"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.data-source.\"jboss.naming.context.java.jboss.datasources.dogsBreedsEeDS\" is missing [jboss.jdbc-driver.com_mysql_jdbc_Driver]"]
}

946 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly Full 20.0.1.Final (WildFly Core 12.0.3.Final) started (with errors) in 6638ms - Started 454 of 688 services (3 services failed or missing dependencies, 378 services are lazy, passive or on-demand)

Can someone tell me why is this happening? Am I doing something wrong?

Thanks a lot

Upvotes: 0

Views: 732

Answers (1)

ehsavoie
ehsavoie

Reputation: 3547

You need to define your driver in the configuration. The "driver" tag doesn't target a class but a name in wildfly configuration.

Upvotes: 1

Related Questions