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

Depois que atualizei o projeto para JSF 2.2 o projeto apresenta erro, detalhe estou usando servidor Jboss EAP 6 e também já tentei com EAP 7

20:54:17,874 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 58) MSC000001: Failed to start service jboss.persistenceunit."livraria.war#livraria": org.jboss.msc.service.StartException in service jboss.persistenceunit."livraria.war#livraria": javax.persistence.PersistenceException: [PersistenceUnit: livraria] Unable to build Hibernate SessionFactory
    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: javax.persistence.PersistenceException: [PersistenceUnit: livraria] Unable to build Hibernate SessionFactory
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882)
    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: org.hibernate.exception.SQLGrammarException: Error creating DatabaseInformation for schema migration
    at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:106)
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:127)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:101)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:470)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)
    ... 9 more
Caused by: org.h2.jdbc.JdbcSQLException: Table "PG_CLASS" not found; SQL statement:
select relname from pg_class where relkind='S' [42102-173]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:331)
    at org.h2.message.DbException.get(DbException.java:171)
    at org.h2.message.DbException.get(DbException.java:148)
    at org.h2.command.Parser.readTableOrView(Parser.java:4864)
    at org.h2.command.Parser.readTableFilter(Parser.java:1107)
    at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1713)
    at org.h2.command.Parser.parseSelectSimple(Parser.java:1821)
    at org.h2.command.Parser.parseSelectSub(Parser.java:1707)
    at org.h2.command.Parser.parseSelectUnion(Parser.java:1550)
    at org.h2.command.Parser.parseSelect(Parser.java:1538)
    at org.h2.command.Parser.parsePrepared(Parser.java:405)
    at org.h2.command.Parser.parse(Parser.java:279)
    at org.h2.command.Parser.parse(Parser.java:251)
    at org.h2.command.Parser.prepareCommand(Parser.java:218)
    at org.h2.engine.Session.prepareLocal(Session.java:428)
    at org.h2.engine.Session.prepareCommand(Session.java:377)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1138)
    at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:72)
    at org.jboss.jca.adapters.jdbc.WrappedStatement.executeQuery(WrappedStatement.java:397)
    at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.extractMetadata(SequenceInformationExtractorLegacyImpl.java:42)
    at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.initializeSequences(DatabaseInformationImpl.java:64)
    at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.<init>(DatabaseInformationImpl.java:60)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:123)
    ... 13 more

20:54:17,884 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Falha na operação ("deploy") - endereço ([("deployment" => "livraria.war")]) - falha na descrição: {"WFLYCTL0080: Falha de serviços" => {"jboss.persistenceunit.\"livraria.war#livraria\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"livraria.war#livraria\": javax.persistence.PersistenceException: [PersistenceUnit: livraria] Unable to build Hibernate SessionFactory
    Caused by: javax.persistence.PersistenceException: [PersistenceUnit: livraria] Unable to build Hibernate SessionFactory
    Caused by: org.hibernate.exception.SQLGrammarException: Error creating DatabaseInformation for schema migration
    Caused by: org.h2.jdbc.JdbcSQLException: Table \"PG_CLASS\" not found; SQL statement:
select relname from pg_class where relkind='S' [42102-173]"}}
20:54:17,919 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Implantado "livraria.war" (runtime-name: "livraria.war")
20:54:17,943 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."livraria.war#livraria": org.jboss.msc.service.StartException in service jboss.persistenceunit."livraria.war#livraria": javax.persistence.PersistenceException: [PersistenceUnit: livraria] Unable to build Hibernate SessionFactory
5 respostas

bom, só posso me guiar pela exception...

Caused by: org.h2.jdbc.JdbcSQLException: Table "PG_CLASS" not found; SQL statement:

Parece que vc ta usando o driver do h2 para consultar uma tabela que deveria estar no postgre, faz sentido? chegou a configurar o driver.

Sim, configurei. Meu 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" transaction-type="RESOURCE_LOCAL">

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

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

        <properties>
            <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/livrariadb" />
            <property name="javax.persistence.jdbc.user" value="postgres" />
            <property name="javax.persistence.jdbc.password" value="123456" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
        </properties>
    </persistence-unit>

</persistence>

Waldeci, ja conseguiu resolver? posta seu resultado aqui.

Caso contrário, uma alternativa é remover todas as tags class, faça o teste.

Consegui encontrar o problema, permissão do usuário CREATEDB OU CREATEROLE. Consegui identificar o problema removendo o

<property name="hibernate.hbm2ddl.auto" value="update" />
solução!

A minha solução foi trocar o Jboss pelo Tomcat