Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

MUDAR DE MY SQL PARA POSTGRES

Estou fazendo o curso Java e JSF l e na aula 3 é pedido para baixa um arquivo que usa o mysql como banco de dados, eu gostaria de usar o postgres que já venho usando em outras aulas e já estou mais familiarizado, ja troquei os dados na persistence:

  <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>

    <properties>
        <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /> <!-- DB Driver -->
        <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost/livrariadb" /> <!-- BD Mane -->
        <property name="javax.persistence.jdbc.user" value="postgres" /> <!-- DB User -->
        <property name="javax.persistence.jdbc.password" value="leozin123" /> <!-- DB Password -->

        <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> <!-- DB Dialect -->
        <property name="hibernate.hbm2ddl.auto" value="update" /> <!-- create / create-drop / update -->            
        <property name="hibernate.show_sql" value="true" /> <!-- Show SQL in console -->
    </properties>

</persistence-unit>

e adicionei o jar do postgres (postgresql-42.3.1.jar) a lib, mas quando chego na parte do curso de rodar a Classe PopulaBanco ocorre esse erro:

Exception in thread "main" java.lang.ExceptionInInitializerError at br.com.caelum.livraria.dao.PopulaBanco.main(PopulaBanco.java:17) Caused by: javax.persistence.PersistenceException: [PersistenceUnit: livraria] Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) at br.com.caelum.livraria.dao.JPAUtil.(JPAUtil.java:10) ... 1 more Caused by: org.hibernate.HibernateException: Error applying BeanValidation relational constraints at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.applyRelationalConstraints(BeanValidationIntegrator.java:219) at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:126) at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:303) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1750) at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:94) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905) ... 6 more Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.applyRelationalConstraints(BeanValidationIntegrator.java:208) ... 11 more Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:468) at org.jboss.logging.Logger.getMessageLogger(Logger.java:2248) at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214) at org.hibernate.validator.internal.util.logging.LoggerFactory.make(LoggerFactory.java:28) at org.hibernate.validator.internal.util.Version.(Version.java:27) at org.hibernate.validator.internal.engine.ConfigurationImpl.(ConfigurationImpl.java:63) at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:41) at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:269) at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111) at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:521) at org.hibernate.cfg.beanvalidation.TypeSafeActivator.applyDDL(TypeSafeActivator.java:119) ... 16 more

1 resposta