1 Reply Latest reply on Dec 26, 2016 5:48 AM by andey

    No Persistence provider for EntityManager named

    hugo.thomaz

      Preciso muito da ajuda de vocês, já há um bom tempo tenho problemas para conseguir usar o servidor JBoss EAP 7 com Datasource NON-XA, JPA e Hibernate 5.

      Quando uso transaction-type="RESOURCE_LOCAL" fica tudo bem, mas quando uso o JTA ocorre uma série de problemas e não conecta.

       

      Segue todas as configurações.

      Detalhe, criei o projeto no braço e depois usei o JBoss Forge, da exatamente o mesmo problema!!!

       

      ...\EAP-7.0.0\modules\system\layers\base\com\mysql\main\module.xml

      <?xml version="1.0" encoding="UTF-8" standalone="no"?>
      <module xmlns="urn:jboss:module:1.0" name="com.mysql">
          <resources>
              <resource-root path="mysql-connector-java-5.1.39-bin.jar"/>
          </resources>
          <dependencies>
              <module name="javax.api"/>
              <module name="javax.transaction.api"/>
          </dependencies>
      </module>
      

       

      ...\EAP-7.0.0\standalone\configuration\standalone.xml

      <datasources>                
                      <datasource jndi-name="java:jboss/datasources/ProjetoDS" pool-name="ProjetoDS" enabled="true">
                          <connection-url>jdbc:mysql://localhost:3306/projeto_db</connection-url>
                          <driver>com.mysql</driver>
                          <pool>
                              <min-pool-size>0</min-pool-size>
                              <max-pool-size>20</max-pool-size>
                          </pool>
                          <security>
                              <user-name>root</user-name>
                              <password>root</password>
                          </security>
                          <validation>
                              <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
                              <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
                          </validation>
                      </datasource>
                      <drivers>                   
                          <driver name="com.mysql" module="com.mysql">
                              <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                          </driver>
                      </drivers>
                  </datasources>
      

       

       

      Arquivo POM.XML:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>meuprojeto</groupId>
        <artifactId>MeuProjeto</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <packaging>war</packaging>
        <build>
        <finalName>MeuProjeto</finalName>
        <plugins>
        <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
        </plugin>
        </plugins>
        </build>
        <dependencies>
      
      
        <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.5.Final</version>
        </dependency>
      
      
        <!-- for JPA, use hibernate-entitymanager instead of hibernate-core -->
        <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>5.2.5.Final</version>
        </dependency>
      
      
        <!-- optional -->
      
      
        <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-osgi</artifactId>
        <version>5.2.5.Final</version>
        </dependency>
        <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-envers</artifactId>
        <version>5.2.5.Final</version>
        </dependency>
        <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-c3p0</artifactId>
        <version>5.2.5.Final</version>
        </dependency>
        <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-proxool</artifactId>
        <version>5.2.5.Final</version>
        </dependency>
        <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-infinispan</artifactId>
        <version>5.2.5.Final</version>
        </dependency>
        <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-ehcache</artifactId>
        <version>5.2.5.Final</version>
        </dependency>
      
      
        <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <scope>provided</scope>
        </dependency>
        </dependencies>
        <dependencyManagement>
        <dependencies>
        <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
        </dependency>
        </dependencies>
        </dependencyManagement>
        <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>
      </project>
      

       

      Entity Grupo: Grupo G

      @Entity
      public class Grupo implements Serializable {
      
      
        private static final long serialVersionUID = 1L;
      
        @Version
        @Column(name = "version")
        private int version;
      
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", nullable = false)
        private Long id;
      
      
      
        @Column(length = 120, nullable = false)
        private String nome;
      
      
      
        public Grupo() {
      
        }
      
      get and set
      
      }
      

       

      Classe JPAUtil:

      public class JPAUtil {
      
        private EntityManagerFactory factory;
        private static JPAUtil instance;
      
        @PersistenceContext(unitName = "ProjectGeneration_PU")
        private EntityManager em;
      
        private JPAUtil(){
        this.factory = Persistence.createEntityManagerFactory("ProjectGeneration_PU");
        }
      
      
        public static synchronized JPAUtil getInstance(){
        if(instance == null){
        instance = new JPAUtil();
        }
        return instance;
        }
      
        public EntityManager getEntityManager(){
        return factory.createEntityManager();
        }
      
      
      }
      

       

      Classe GenericDAO:

      public abstract class GenericDAO<T extends Serializable> {
      
      
        private Class<T> aClass;
      
      
        protected GenericDAO(Class<T> aClass) {
        this.aClass = aClass;
        }
      
      
        protected EntityManager getEntityManager() {
        return JPAUtil.getInstance().getEntityManager();
        }
      
      
        public void save(T entity) {
        EntityManager manager = getEntityManager();
        manager.getTransaction().begin();
      
      
        manager.persist(entity);
      
      
        manager.getTransaction().commit();
      
      
        manager.close();
      
      
        }
      
      
        public void update(T entity) {
        EntityManager manager = getEntityManager();
        manager.getTransaction().begin();
        manager.merge(entity);
        manager.getTransaction().commit();
        manager.close();
        }
      
      
        public void delete(Integer id) {
        EntityManager manager = getEntityManager();
        manager.getTransaction().begin();
        // manager.remove(manager.find(aClass, id));
        manager.remove(manager.getReference(aClass, id));
        manager.getTransaction().commit();
        manager.close();
        }
      
      
        public void delete(T entity) {
        EntityManager manager = getEntityManager();
        manager.getTransaction().begin();
        // manager.remove(manager.find(aClass, id));
        manager.remove(manager.merge(entity));
        manager.getTransaction().commit();
        manager.close();
        }
      
      
        @SuppressWarnings("unchecked")
        public T findOne(String jpql, Object... params) {
        EntityManager manager = getEntityManager();
        manager.getTransaction().begin();
        Query query = manager.createQuery(jpql);
      
      
        for (int i = 0; i < params.length; i++) {
        query.setParameter(i + 1, params[i]);
        }
      
      
        T entity = (T) query.getSingleResult();
      
      
        manager.getTransaction().commit();
        manager.close();
      
      
        return entity;
        }
      
      
        public T findByID(Integer id) {
        EntityManager manager = getEntityManager();
        manager.getTransaction().begin();
      
      
        T entity = manager.find(aClass, id);
      
      
        manager.getTransaction().commit();
        manager.close();
      
      
        return entity;
        }
      
      
        @SuppressWarnings({ "unchecked" })
        public List<T> find(String jpql, Object... params) {
        EntityManager manager = getEntityManager();
        manager.getTransaction().begin();
        Query query = manager.createQuery(jpql);
      
      
        for (int i = 0; i < params.length; i++) {
        query.setParameter(+1, params[i]);
        }
      
      
        List<T> entities = query.getResultList();
      
      
        return entities;
        }
      
      
        public long count() {
        EntityManager manager = getEntityManager();
        manager.getTransaction().begin();
      
      
        Query query = manager.createQuery("select count(c) from" + aClass.getName() + " c");
        long count = (Long) query.getSingleResult();
      
      
        manager.getTransaction().commit();
        manager.clear();
      
      
        return count;
        }
      
      
      }
      

       

       

      Classe GrupoDAO:

      public class GrupoDao extends GenericDAO<Grupo>{
      
      
        public GrupoDao() {
        super(Grupo.class);
        // TODO Auto-generated constructor stub
        }
      
      }
      

       

       

      Classe Testando:

      public class Testando {
      
       public static void main(String[] args) {
      
        Grupo grupo = new Grupo();
        grupo.setNome("Hugo");
      
      
      
        GrupoDao dao = new GrupoDao();
      
        dao.save(grupo);
      
        }
      
      }
      

       

       

       

       

       

      Erros ao iniciar o servidor:

      02:40:50,784 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.1.Final-redhat-1
      02:40:51,031 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final-redhat-1
      02:40:51,121 INFO  [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: Iniciando JBoss EAP 7.0.0.GA (WildFly Core 2.1.2.Final-redhat-1)
      02:40:52,115 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0015: A nova tentativa implantação de ProjectGeneration.jar falhou 
      02:40:52,122 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Encontrado ProjectGeneration.jar no diretório da implantação. Crie um arquivo chamado ProjectGeneration.jar.dodeploy para aplicar o trigger na implantação
      02:40:52,122 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Encontrado MeuProjeto.war no diretório da implantação. Crie um arquivo chamado MeuProjeto.war.dodeploy para aplicar o trigger na implantação
      02:40:52,151 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Criação de serviço de gerenciamento http usando o socket-binding (management-http)
      02:40:52,166 INFO  [org.xnio] (MSC service thread 1-5) XNIO version 3.3.6.Final-redhat-1
      02:40:52,172 INFO  [org.xnio.nio] (MSC service thread 1-5) XNIO NIO Implementation Version 3.3.6.Final-redhat-1
      02:40:52,206 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 38) WFLYCLINF0001: Ativação do subsistema Infinispan.
      02:40:52,215 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 37) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors
      02:40:52,216 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 54) WFLYTX0013: A propriedade de identificador do nó é configurado ao valor default. Por favor certifique-se de que isto é único.
      02:40:52,225 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 56) WFLYWS0002: Ativação da Extensão WebServices
      02:40:52,220 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 44) WFLYJSF0007: As seguintes implantações JSF foram ativadas: [main]
      02:40:52,228 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 53) WFLYSEC0002: Ativação do Subsistema de Segurança
      02:40:52,316 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 46) WFLYNAM0001: Ativação do Subsistema de Nomeação
      02:40:52,323 INFO  [org.jboss.as.security] (MSC service thread 1-8) WFLYSEC0001: Versão =4.9.6.Final-redhat-1 PicketBox Atual
      02:40:52,324 INFO  [org.jboss.as.connector] (MSC service thread 1-6) WFLYJCA0009: Inicialização JCA do Subsistema (WildFly/IronJacamar 1.3.3.Final-redhat-1)
      02:40:52,349 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0003: Undertow 1.3.21.Final-redhat-1 starting
      02:40:52,349 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0003: Undertow 1.3.21.Final-redhat-1 starting
      02:40:52,353 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0004: Implantação do driver compatível-JDBC class org.h2.Driver (versão 1.3)
      02:40:52,358 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) WFLYJCA0018: Started Driver service with driver-name = h2
      02:40:52,367 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
      02:40:52,367 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) WFLYJCA0018: Started Driver service with driver-name = com.mysql
      02:40:52,370 INFO  [org.jboss.as.naming] (MSC service thread 1-7) WFLYNAM0003: Iniciando o Serviço de Nomeação
      02:40:52,370 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-4) WFLYMAIL0001: Sessão de correio limitado [java:jboss/mail/Default]
      02:40:52,461 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path 'D:\Ferramentas\AplicationServer\EAP-7.0.0/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
      02:40:52,559 INFO  [org.jboss.as.ejb3] (MSC service thread 1-8) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 32 (per class), which is derived from the number of CPUs on this host.
      02:40:52,560 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0012: Started server default-server.
      02:40:52,560 INFO  [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 128 (per class), which is derived from thread worker pool sizing.
      02:40:52,565 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0018: Host default-host starting
      02:40:52,573 INFO  [org.jboss.remoting] (MSC service thread 1-4) JBoss Remoting version 4.0.18.Final-redhat-1
      02:40:52,613 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
      02:40:52,725 INFO  [org.jboss.as.connector.subsystems.datasources.AbstractDataSourceService$AS7DataSourceDeployer] (MSC service thread 1-8) IJ020018: Enabling <validate-on-match> for java:jboss/datasources/ProjetoDS
      02:40:52,759 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) WFLYJCA0001: Limite da fonte de dados [java:jboss/datasources/ExampleDS]
      02:40:52,759 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) WFLYJCA0001: Limite da fonte de dados [java:jboss/datasources/ProjetoDS]
      02:40:52,841 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0027: Iniciando a implantação do "MeuProjeto.war" (runtime-name: "MeuProjeto.war")
      02:40:52,841 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Iniciando a implantação do "ProjectGeneration.jar" (runtime-name: "ProjectGeneration.jar")
      02:40:52,853 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-6) WFLYDS0013: Foi iniciado o FileSystemDeploymentService para o diretório D:\Ferramentas\AplicationServer\EAP-7.0.0\standalone\deployments
      02:40:52,979 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-2) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.2.Final-redhat-1
      02:40:53,017 INFO  [org.jboss.ws.common.management] (MSC service thread 1-3) JBWS022052: Starting JBossWS 5.1.3.SP1-redhat-1 (Apache CXF 3.1.4.redhat-1) 
      02:40:53,061 INFO  [org.jboss.as.jpa] (MSC service thread 1-7) WFLYJPA0002: Leia a persistence.xml para ProjectGeneration
      02:40:53,141 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 58) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'ProjectGeneration.jar#ProjectGeneration'
      02:40:53,167 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 58) HHH000204: Processing PersistenceUnitInfo [
        name: ProjectGeneration
        ...]
      02:40:53,455 INFO  [org.hibernate.Version] (ServerService Thread Pool -- 58) HHH000412: Hibernate Core {5.0.9.Final-redhat-1}
      02:40:53,459 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 58) HHH000206: hibernate.properties not found
      02:40:53,461 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 58) HHH000021: Bytecode provider name : javassist
      02:40:53,504 INFO  [org.hibernate.orm.deprecation] (ServerService Thread Pool -- 58) HHH90000001: Found usage of deprecated setting for specifying Scanner [hibernate.ejb.resource_scanner]; use [hibernate.archive.scanner] instead
      02:40:53,514 INFO  [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 58) HCANN000001: Hibernate Commons Annotations {5.0.1.Final-redhat-2}
      02:40:53,577 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 58) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'ProjectGeneration.jar#ProjectGeneration'
      02:40:53,835 INFO  [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 58) HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
      02:40:53,842 WARN  [org.hibernate.dialect.H2Dialect] (ServerService Thread Pool -- 58) HHH000431: Unable to determine H2 database version, certain features may not work
      02:40:53,884 INFO  [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 58) Envers integration enabled? : true
      02:40:53,962 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 58) MSC000001: Failed to start service jboss.persistenceunit."ProjectGeneration.jar#ProjectGeneration": org.jboss.msc.service.StartException in service jboss.persistenceunit."ProjectGeneration.jar#ProjectGeneration": org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [devmedia.beans.Grupo]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172)
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117)
        at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667)
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
        at org.jboss.threads.JBossThread.run(JBossThread.java:320)
      Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [devmedia.beans.Grupo]
        at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:229)
        at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.<init>(AnnotationMetadataSourceProcessorImpl.java:103)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.<init>(MetadataBuildingProcess.java:147)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:141)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874)
        at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154)
        ... 7 more
      Caused by: java.lang.ClassNotFoundException: Could not load requested class : devmedia.beans.Grupo
        at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:217)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:226)
        ... 14 more
      02:40:55,334 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) WFLYJPA0002: Leia a persistence.xml para ProjectGeneration_PU
      02:40:55,568 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 58) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'MeuProjeto.war#ProjectGeneration_PU'
      02:40:55,568 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 58) HHH000204: Processing PersistenceUnitInfo [
        name: ProjectGeneration_PU
        ...]
      02:40:55,581 WARN  [org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl] (ServerService Thread Pool -- 58) HHH000059: Defining hibernate.transaction.flush_before_completion=true ignored in HEM
      02:40:55,582 INFO  [org.hibernate.orm.deprecation] (ServerService Thread Pool -- 58) HHH90000001: Found usage of deprecated setting for specifying Scanner [hibernate.ejb.resource_scanner]; use [hibernate.archive.scanner] instead
      02:40:55,597 INFO  [org.jboss.weld.deployer] (MSC service thread 1-8) WFLYWELD0003: Processamento da implantação weld MeuProjeto.war
      02:40:55,665 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-8) HV000001: Hibernate Validator 5.2.4.Final-redhat-1
      02:40:55,841 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0006: Iniciando os  Serviços para a implantação CDI: MeuProjeto.war
      02:40:55,871 INFO  [org.jboss.weld.Version] (MSC service thread 1-2) WELD-000900: 2.3.3 (redhat)
      02:40:55,899 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) WFLYWELD0009: Inicialização do serviço weld para a implantação MeuProjeto.war
      02:40:56,040 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 58) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'MeuProjeto.war#ProjectGeneration_PU'
      02:40:56,169 ERROR [stderr] (ServerService Thread Pool -- 58) Mon Nov 28 02:40:56 BRST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
      02:40:56,278 INFO  [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 58) HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
      02:40:56,304 INFO  [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 58) Envers integration enabled? : true
      02:40:56,654 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 58) HHH000227: Running hbm2ddl schema export
      02:40:56,662 INFO  [stdout] (ServerService Thread Pool -- 58) Hibernate: 
      02:40:56,662 INFO  [stdout] (ServerService Thread Pool -- 58)     drop table if exists Grupo
      02:40:56,670 INFO  [stdout] (ServerService Thread Pool -- 58) Hibernate: 
      02:40:56,670 INFO  [stdout] (ServerService Thread Pool -- 58)     create table Grupo (
      02:40:56,671 INFO  [stdout] (ServerService Thread Pool -- 58)         id bigint not null auto_increment,
      02:40:56,671 INFO  [stdout] (ServerService Thread Pool -- 58)         nome varchar(120) not null,
      02:40:56,671 INFO  [stdout] (ServerService Thread Pool -- 58)         version integer,
      02:40:56,671 INFO  [stdout] (ServerService Thread Pool -- 58)         primary key (id)
      02:40:56,671 INFO  [stdout] (ServerService Thread Pool -- 58)     )
      02:40:57,071 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 58) HHH000230: Schema export complete
      02:40:57,626 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 62) WFLYUT0021: Registered web context: /MeuProjeto
      02:40:57,631 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Falha na operação ("deploy") - endereço ([("deployment" => "ProjectGeneration.jar")]) - falha na descrição: {"WFLYCTL0080: Falha de serviços" => {"jboss.persistenceunit.\"ProjectGeneration.jar#ProjectGeneration\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"ProjectGeneration.jar#ProjectGeneration\": org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [devmedia.beans.Grupo]
          Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [devmedia.beans.Grupo]
          Caused by: java.lang.ClassNotFoundException: Could not load requested class : devmedia.beans.Grupo"}}
      02:40:57,650 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Implantado "ProjectGeneration.jar" (runtime-name: "ProjectGeneration.jar")
      02:40:57,651 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Implantado "MeuProjeto.war" (runtime-name: "MeuProjeto.war")
      02:40:57,651 INFO  [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Relatório
       de status de serviço WFLYCTL0186: Serviços que falham na inicialização:      service jboss.persistenceunit."ProjectGeneration.jar#ProjectGeneration": org.jboss.msc.service.StartException in service jboss.persistenceunit."ProjectGeneration.jar#ProjectGeneration": org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [devmedia.beans.Grupo]
      02:40:57,767 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: A interface do gerenciamento ouvindo no http://127.0.0.1:9990/management
      02:40:57,767 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: O console de administração ouvindo no http://127.0.0.1:9990
      02:40:57,767 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: JBoss EAP 7.0.0.GA (WildFly Core 2.1.2.Final-redhat-1) iniciado (com erros) em 7292ms - Iniciado 405 de serviços 702 (2 serviços falharam ou faltam dependência, os serviços 391 são lazy, passivos ou em demanda)
      02:40:57,797 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 62) WFLYJPA0011: Stopping Persistence Unit (phase 1 of 2) Service 'ProjectGeneration.jar#ProjectGeneration'
      02:40:57,807 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0028: Implantação encerrada ProjectGeneration.jar (runtime-name: ProjectGeneration.jar) em 13ms
      02:40:57,863 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0009: Desimplantado "ProjectGeneration.jar" (runtime-name: "ProjectGeneration.jar")
      02:40:57,864 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 1) WFLYCTL0183: Relatório
       de status de serviço WFLYCTL0184: Não falta/insatisfaz nenhuma das dependências:
      service jboss.persistenceunit."ProjectGeneration.jar#ProjectGeneration" (faltam) dependentes: [service jboss.deployment.unit."ProjectGeneration.jar".deploymentCompleteService] 
      WFLYCTL0186: Serviços que falham na inicialização:      service jboss.persistenceunit."ProjectGeneration.jar#ProjectGeneration"
      02:41:02,705 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Encontrado ProjectGeneration.jar no diretório da implantação. Crie um arquivo chamado ProjectGeneration.jar.dodeploy para aplicar o trigger na implantação
      
      

       

       

       

       

      Erro ao iniciar a classe Testando.java:

      Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named ProjectGeneration_PU
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
        at meuprojeto.util.JPAUtil.<init>(JPAUtil.java:17)
        at meuprojeto.util.JPAUtil.getInstance(JPAUtil.java:23)
        at meuprojeto.dao.GenericDAO.getEntityManager(GenericDAO.java:20)
        at meuprojeto.dao.GenericDAO.save(GenericDAO.java:24)
        at meuprojeto.teste.Testando.main(Testando.java:16)
      
        • 1. Re: No Persistence provider for EntityManager named
          andey

          Hi,

           

           

          Root causing this error:

           

          1# missing META-INF/services/javax.persistence.spi.PersistenceProvider file. for hibernate, it's located in hibernate-entitymanager-XXX.jar, so, if hibernate-entitymanager-XXX.jar is not in your classpath, you will got this error too.

           

          2#  Verify your persistence.xml whether it is  in the right location or not :

           

          ~~~

          project/src/main/resources/META-INF/persistence.xml

          ~~~

           

          You will need to move the persistence.xml file to an appropriate location

           

           

          From JPA spec:

           

           

          A persistence.xml file defines a persistence unit. The persistence.xml file is

          located in the META-INF directory of the root of the persistence unit.

          The root of the persistence unit is the key here.

           

           

          If you are a non-Java EE app

           

           

          The jar file or directory whose META-INF directory contains the persistence.xml

          file is termed the root of the persistence unit.

          If you are in a Java EE app, the following are valid

           

           

          In Java EE environments, the root of a persistence unit must be one of the following:

          • an EJB-JAR file

          • the WEB-INF/classes directory of a WAR file

          • a jar file in the WEB-INF/lib directory of a WAR file

          • a jar file in the EAR library directory

          • an application client jar file

           

           

           

          3# Verify the  provider class in persistence.xml:

          For Hibernate it should be:

          ~~~

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

          ~~~

           

          4# hibernate-core 5.2.5.Final is *nt* still tested and supported By Red Hat JBoss. use hibernate-core 5.0.9.Final as hibernate core components.

           

           

           

          Regards,
          Anup