INFO: Could not find any META-INF/persistence.xml file in the classpath / PersistenceException

7 respostas
L

Pessoal,

estou fazendo um exemplo de JPA com Netbeans 7, e usando as bibliotecas todas adicionadas pelo wizard dele mesmo. Daí, quando vou
chamar o método ‘getTodosUsuariosComOperacao’ conforme abaixo, ele fala que o arquivo ‘persistence.xml’ não está no classpath (como assim??). Só que o arquivo existe e está em ‘META-INF’.

INFO: Could not find any META-INF/persistence.xml file in the classpath
javax.persistence.PersistenceException: No Persistence provider for EntityManager named gestao
	at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
	at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
	at pkgdao.DaoUsuario.<init>(DaoUsuario.java:30)
	at pkgcontroller.ControllerUsuario.getTodosUsuariosComOperacao(ControllerUsuario.java:86)

Estou achando estranho também porque estou usando toplink, mas analisando o debug as mensagens são de annotations, conforme abaixo:

26/04/2011 16:52:37 org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.1.GA
26/04/2011 16:52:40 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.5
26/04/2011 16:52:40 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
26/04/2011 16:52:40 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
26/04/2011 16:52:41 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
26/04/2011 16:52:44 org.hibernate.ejb.Version <clinit>
INFO: Hibernate EntityManager 3.3.2.GA
26/04/2011 16:52:45 org.hibernate.ejb.Ejb3Configuration configure

Meu persistence.xml está assim, sendo ‘gestao’ o nome do banco mysql (algum problema em ser o nome do banco??):

<?xml version="1.0" encoding="UTF-8"?>
<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 persistence_1_0.xsd"
  version="1.0">
  
  <persistence-unit name="gestao" transaction-type="RESOURCE_LOCAL">
    <provider>oracle.toplink.essentials.PersistenceProvider</provider>
    <class>pkgusuario.Usuario</class>
    <class>pkgauditoria.Auditoria</class>
    <properties>
      <property name="toplink.logging.level" value="FINE"/>
      <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
      <property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/gestao"/>
      <property name="toplink.jdbc.user" value="root"/>
      <property name="toplink.jdbc.password" value="root"/>
    </properties>
  </persistence-unit>
</persistence>

Alguém pode ajudar?

7 Respostas

S

O META-INF ta no src ( source ) do teu projeto?

L

Sim,

como estou usando NB, está assim:

Projeto

Páginas web

META-INF\persistence.xml
META-INF\context.xml

??

L

tah com cara de falta de jar´s…reveja as bibliotecas suas!

L

As libs que estou usando são:
-mysql-connector-java-5.1.15-bin.jar
-jsf-api.jar
-jsf-impl.jar
-standard.jar
-jstl.jar
-toplink-essentials.jar
-toplink-essentials-agent.jar

Tem que adicionar as do Hibernate e ejb também?

L

Amigo o erro q informa ali em cima é do hibernate e vc usa no persistence o toplink, esse seu persistence.xml axo q está na pasta errada, veja onde deve ficar:

L

Seguem as libs com as quais estou trabalhando e o local do persistence.xml…

O que mais poderia ser?

B

to com o msm problema, conseguiu a solução??

Criado 26 de abril de 2011
Ultima resposta 25 de set. de 2012
Respostas 7
Participantes 4