Erro Jpa

4 respostas
gismo

Boa Tarde,

Alguem sabe o que é esse erro?

12/01/2011 13:12:07 org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.1.GA
12/01/2011 13:12:07 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.5
12/01/2011 13:12:07 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
12/01/2011 13:12:07 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
12/01/2011 13:12:07 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
12/01/2011 13:12:07 org.hibernate.ejb.Version <clinit>
INFO: Hibernate EntityManager 3.3.2.GA
12/01/2011 13:12:29 org.hibernate.ejb.packaging.PersistenceXmlLoader$ErrorLogger warning
WARNING: Warning parsing XML: XML InputStream(3) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named JpaTestePU
        at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
        at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
        at br.com.entidades.UsuariosJpaController.<init>(UsuariosJpaController.java:26)
        at br.com.entidades.Teste.main(Teste.java:14)
Java Result: 1

OBS: Uso NetBeans, as classes são geradas por ele.
OBS2: O jar EntityManager ta no projeto já.

Obrigado.

4 Respostas

A

Tem que configurar no seu persistence.xml qual a implementação de JPA que vc vai utilizar. Parece que isso é o que está faltando. Está com o jar do hibernate-entity-manager no classpath? Se o jar tiver lá tb deveria funcionar sem precisar configurar nada no persistence.

Alberto

gismo

O persistence.xml ta configurado sim, o NetBeans gera ele automaticamente.

gismo

Achei no fórum um cara com o mesmo erro que o meu, ele resolveu baixando as libs do eclipselink novamente, fiz a mesma coisa e funcionou…

Só que agora está dando esse erro:

[EL Info]: 2011-01-12 21:38:59.828--ServerSession(249613347)--EclipseLink, version: Eclipse Persistence Services - 2.1.2.v20101206-r8635
[EL Info]: 2011-01-12 21:39:00.14--ServerSession(249613347)--file:/C:/Users/Thiago/Documents/NetBeansProjects/JpaTomCat/build/web/WEB-INF/classes/_JpaTomCatPU login successful
12/01/2011 21:39:00 br.com.entidades.Teste main
SEVERE: null
java.lang.IllegalArgumentException: Unknown entity bean class: class br.com.entidades.Usuarios, please verify that this class has been marked with the @Entity annotation.
        at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:611)
        at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:495)
        at br.com.entidades.UsuariosJpaController.findUsuarios(UsuariosJpaController.java:124)
        at br.com.entidades.UsuariosJpaController.create(UsuariosJpaController.java:42)
        at br.com.entidades.Teste.main(Teste.java:15)

E a classe está sim marcada com @Entity.

Obrigado

gismo

Adicionei os jars do hibernate e deu certo ;].

Vlw

Criado 12 de janeiro de 2011
Ultima resposta 12 de jan. de 2011
Respostas 4
Participantes 2