Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Aula 3. Atividade 8: Não está criando as tabelas automaticamente

Olá pessoal! Acabei de configurar o datasource no standalone.xml. Criei o schema no mysql, criei a modules na posta do Jboss. Não da erro nenhum mas não cria as tabelas automaticamente de jeito nenhum!

Estou usando Jboss 7.1.1, MySQL workbench 6.3

Log ao subir o Jboss 7.1.1 no Eclipse

23:06:53,832 INFORMAÇÕES [org.jboss.modules] JBoss Modules version 1.1.1.GA
23:06:54,112 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
23:06:54,192 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
23:06:55,416 INFO  [org.xnio] XNIO Version 3.0.3.GA
23:06:55,417 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
23:06:55,430 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
23:06:55,439 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
23:06:55,481 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
23:06:55,511 INFO  [org.jboss.as.osgi] JBAS011940: Activating OSGi Subsystem
23:06:55,510 INFO  [org.jboss.as.clustering.infinispan] JBAS010280: Activating Infinispan subsystem.
23:06:55,507 INFO  [org.jboss.as.naming] JBAS011800: Activating Naming Subsystem
23:06:55,507 INFO  [org.jboss.as.configadmin] JBAS016200: Activating ConfigAdmin Subsystem
23:06:55,524 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
23:06:55,532 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
23:06:55,648 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
23:06:55,665 INFO  [org.jboss.as.security] (MSC service thread 1-2) JBAS013100: Current PicketBox version=4.0.7.Final
23:06:55,723 INFO  [org.jboss.as.connector] (MSC service thread 1-5) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
23:06:55,785 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
23:06:55,830 INFO  [org.jboss.as.naming] (MSC service thread 1-5) JBAS011802: Starting Naming Service
23:06:55,833 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-10) JBoss Web Services - Stack CXF Server 4.0.2.GA
23:06:55,836 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-5) JBAS015400: Bound mail session [java:jboss/mail/Default]
23:06:56,425 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-3) Starting Coyote HTTP/1.1 on http-localhost-127.0.0.1-8080
23:06:56,570 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-12) JBAS015012: Started FileSystemDeploymentService for directory C:\Java\jboss-as-7.1.1.Final\standalone\deployments
23:06:56,571 INFO  [org.jboss.as.remoting] (MSC service thread 1-4) JBAS017100: Listening on /0.0.0.0:9998
23:06:56,571 INFO  [org.jboss.as.remoting] (MSC service thread 1-7) JBAS017100: Listening on localhost/127.0.0.1:4447
23:06:56,576 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found livraria.war in deployment directory. To trigger deployment create a file called livraria.war.dodeploy
23:06:56,695 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-11) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
23:06:56,700 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:/livrariaDS]
23:06:56,730 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://0.0.0.0:9990
23:06:56,731 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 3293ms - Started 137 of 213 services (74 services are passive or on-demand)

Meu 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</connection-url>
                    <driver>h2</driver>
                    <security>
                        <user-name>sa</user-name>
                        <password>sa</password>
                    </security>
                </datasource>
                <datasource jndi-name="java:/livrariaDS" 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>senha</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.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
        http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">

    <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 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>
    </persistence-unit>
</persistence>

O que estou fazendo de errado?

Muito obrigado!

2 respostas

Eu acho que ele não está deployando seu projeto de forma automática... Agora não sei exatamente porque. De todo jeito, troca para o wildfly mais novo, só para não usar uma versão tao antiga.

solução!

Olá Alberto!

Agora vi o que aconteceu. Fiz besteira. Eu tinha adicionado o arquivo persitence.xml no diretório META-INF dentro de WebContent e não dentro de src como deve ser.

Agora funcionou! Fica aí pra quem puder ter esse mesmo problema!

Obrigado!