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

FALHA DURANTE O START DO WILDFLY COM O MYSQL

Conseguir start do wildfly com as configuarações no datasource. e modelo. este sameDATASOURCE, mas quando adiciono o projeto no server da erros. Estou com duvida no persistence.xml.

13:41:12,922 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
13:41:13,172 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) WFLYDS0013: Started FileSystemDeploymentService for directory C:\wildfly-10.0.0.Final\standalone\deployments
13:41:13,469 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) WFLYJCA0001: Bound data source [java:jboss/datasources/sameDATASOURCE]
13:41:13,469 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
13:41:13,531 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-7) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.0.Final
13:41:13,531 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-8) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.0.Final
13:41:13,687 INFO  [org.jboss.ws.common.management] (MSC service thread 1-2) JBWS022052: Starting JBossWS 5.1.3.Final (Apache CXF 3.1.4) 
13:41:13,991 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
13:41:13,991 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
13:41:13,991 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.0.0.Final (WildFly Core 2.0.10.Final) started in 5962ms - Started 274 of 560 services (372 services are lazy, passive or on-demand)

Pra chegar a esse resultado fiz um outro exemplo pois a atividade da aula do curso não conseguir, essas configurações fiz no standalone.xml.

 <datasource jndi-name="java:jboss/datasources/sameDATASOURCE" pool-name="MySQL" enabled="true" use-java-context="true">
                    <connection-url>jdbc:mysql://localhost:3306/samedb</connection-url>
                    <driver>mysql</driver>
                    <security>
                        <user-name>root</user-name>
                        <password>123456</password>
                    </security>
                </datasource>
                <drivers>
            <driver name="mysql" module="com.mysql">
                        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                    </driver>
                </drivers>

Persistence.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        version="2.1"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
    http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="casadocodigo-dev" transaction-type="JTA">
        <description>Dev persistence unit</description>
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <!-- java transaction api || JNDI -->
        <jta-data-source>java:jboss/datasources/sameDATASOURCE</jta-data-source>
        <properties>
            <property name="hibernate.hbm2ddl.auto" value="update"/>
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
        </properties>
    </persistence-unit>
</persistence>

Nessa linha o "name " seria de onde , da minha base de dados , datasource, banco.. ?

   <persistence-unit name="casadocodigo-dev" transaction-type="JTA">
2 respostas

Um persistence-unit é definido por um elemento XML de unidade de persistência. O atributo name necessário ("casadocodigo-dev" no exemplo) identifica a unidade de persistência ao instanciar um EntityManager:

@PersistenceContext(unitName="casadocodigo-dev")
private EntityManager manager;

Mas não é obrigatorio informar se houver apenas uma opção configurada que possa ser escolhida pelo JPA.

solução!

Deu certo. e tbm copiei a pasta META-INF com o persistence.xml para a pasta webapp. e deu certinho. Valeu !!

@PersistenceContext(unitName="casadocodigo-dev")
private EntityManager manager;