2
respostas

Erro no Deploy de livraria

Estou com erro ao realizar o deploy no projeto livraria, conforme contéudo abaixo, estou usando mysql, wildfly 10



12:14:33,875 INFO  [org.jboss.weld.Version] (MSC service thread 1-5) WELD-000900: 2.3.5 (Final)
12:14:34,137 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 62) WFLYCLINF0002: Started client-mappings cache from ejb container
12:14:34,213 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "livraria.war")]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.livrariaDS"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "jboss.persistenceunit.\"livraria.war#livraria\" is missing [jboss.naming.context.java.livrariaDS]",
        "jboss.persistenceunit.\"livraria.war#livraria\".__FIRST_PHASE__ is missing [jboss.naming.context.java.livrariaDS]"
    ]
}
12:14:34,238 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "livraria.war" (runtime-name : "livraria.war")
12:14:34,272 INFO  [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184:    New missing/unsatisfied dependencies:
      service jboss.naming.context.java.livrariaDS (missing) dependents: [service jboss.persistenceunit."livraria.war#livraria".__FIRST_PHASE__, service jboss.persistenceunit."livraria.war#livraria"]
<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 jndi-name="java:/livraria" pool-name="livrariaDS"    enabled="true" use-java-context="true">
                    <connection-url>jdbc:mysql://localhost:3306/livraria</connection-url>
                    <driver>com.mysql</driver>
                    <pool>
                        <min-pool-size>10</min-pool-size>
                        <max-pool-size>100</max-pool-size>
                        <prefill>true</prefill>
                    </pool>
                    <security>
                        <user-name>root</user-name>
                        <password>123456</password>
                    </security>
                </datasource>

                <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                    <driver name="com.mysql" module="com.mysql">
                        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>
    <persistence-unit name="livraria">

        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <jta-data-source>java:/livrariaDS</jta-data-source>

        <class>br.com.caelum.livraria.modelo.Autor</class>
        <class>br.com.caelum.livraria.modelo.Livro</class>
        <class>br.com.caelum.livraria.modelo.Usuario</class>

        <properties>

            <!-- Configuracoes da conexao -->
<!--             <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" /> -->
<!--             <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/fj25" /> -->
<!--             <property name="javax.persistence.jdbc.user" value="root" /> -->
<!--             <property name="javax.persistence.jdbc.password" value="123456" /> -->

            <!-- Configuracoes especificas do Hibernate -->
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.show_sql" value="true" />

        </properties>
2 respostas

Boa tarde Carlos, tenta usar:

<datasource jndi-name="java:/livrariaDS"

ao invés de :

<datasource jndi-name="java:/livraria"

Oi Carlos!

O valor do jta-data-source no persistence.xml tem que corresponder ao atributo jndi-name data tag datasource do seu standalone.xml. É só deixar os dois assim que deve funconar:

<jta-data-source>java:/livrariaDS</jta-data-source>
<datasource jndi-name="java:/livrariaDS"  ... >

Abraço!