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?

