Alo pessoal, escrevi um sistema com dao/jdbc, e estou estudando jpa+hibernate para tentar trocar o dao.
Estou seguindo a apostila K19-21 persistencia jpa e hibernate, e esta ocorrendo erro ao chamar o EntityManagerFactory, já revisei varios topicos do forum com o mesmo problema e nenhum resolveu o meu problema.
Sei que é repetitivo, e agradeço pela ajuda.
segue abaixo o console
0 [main] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.5.1-Final
44 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.5.1-Final
48 [main] INFO org.hibernate.cfg.Environment - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.postgresql.Driver, hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, hibernate.format_sql=true, hibernate.connection.username=postgres, hibernate.session_factory_name=siae, hibernate.hbm2ddl.auto=create, hibernate.connection.url=jdbc:postgresql:siae_hibernate, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, hibernate.connection.password=****}
56 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
69 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
129 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
130 [main] INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.5.1-Final
Exception in thread “main” javax.persistence.PersistenceException: Unable to configure EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:371)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at GeraTabelas.main(GeraTabelas.java:10)
Caused by: java.lang.NullPointerException
at org.hibernate.ejb.packaging.PersistenceXmlLoader.getStreamFromClasspath(PersistenceXmlLoader.java:152)
at org.hibernate.ejb.packaging.PersistenceXmlLoader.loadURL(PersistenceXmlLoader.java:89)
at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:168)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:310)
… 4 more
a classe
import java.io.Serializable;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
public class GeraTabelas implements Serializable {
public static void main(String[] args) {
EntityManagerFactory factory =
Persistence.createEntityManagerFactory(“siae”);
factory.close();
}
}
persistence.xml
hibernate.properties
Pessoal, resolvi o problema, estava usando as libs no user-lib do eclipse.
Coloquei as libs direto no buildpath e agora funcionou.
Fica a dica pra quem esta tentando tambem.