JPA com erro

Estou tentando da uma testada na JPA. Porem esta acontecendo o seguinte erro

[quote]Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named persistencia: No META-INF/persistence.xml was found in classpath[/quote].

Esta é a minha classe:

[code]Associado
/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor.
    */
    package persistencia;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
*

  • @author Rafael Ferreira
    */
    @Entity
    @Table(name = "associado")
    @NamedQueries({@NamedQuery(name = "Associado.findByAssCodigo",
    query = "SELECT a FROM Associado a WHERE a.assCodigo = :assCodigo"),
    @NamedQuery(name = "Associado.findByAssNome",
    query = "SELECT a FROM Associado a WHERE a.assNome = :assNome")
    })
    public class Associado implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "ass_codigo", nullable = false)
    private Integer assCodigo;
    @Column(name = "ass_nome")
    private String assNome;

    public Associado() {
    }
    public Associado (Integer codigo, String nome){
    setAssCodigo(codigo);
    setAssNome(nome);
    }

    public Associado(Integer assCodigo) {
    this.assCodigo = assCodigo;
    }

    public Integer getAssCodigo() {
    return assCodigo;
    }

    public void setAssCodigo(Integer assCodigo) {
    this.assCodigo = assCodigo;
    }

    public String getAssNome() {
    return assNome;
    }

    public void setAssNome(String assNome) {
    this.assNome = assNome;
    }

    @Override
    public int hashCode() {
    int hash = 0;
    hash += (assCodigo != null ? assCodigo.hashCode() : 0);
    return hash;
    }

    @Override
    public boolean equals(Object object) {
    // TODO: Warning - this method won’t work in the case the id fields are not set
    if (!(object instanceof Associado)) {
    return false;
    }
    Associado other = (Associado) object;
    if ((this.assCodigo == null && other.assCodigo != null) || (this.assCodigo != null && !this.assCodigo.equals(other.assCodigo))) {
    return false;
    }
    return true;
    }

    @Override
    public String toString() {
    return "persistencia.Associado[assCodigo=" + assCodigo + "]";
    }
    } [/code

[code]package persistencia;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;

/**
*

  • @author Administrador
    */
    public class Main {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      Associado associado = new Associado();
      associado.setAssCodigo(new Integer(1));
      associado.setAssNome("Teste");
      salva(associado);

    }

    public static void persist(Object object) {
    EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("persistencia");
    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    try {
    em.persist(object);
    em.getTransaction().commit();
    } catch (Exception e) {
    e.printStackTrace();
    em.getTransaction().rollback();
    } finally {
    em.close();
    }
    }

    public static void salva(Object object){

     EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistencia");   
     EntityManager em = emf.createEntityManager();   
     EntityTransaction tx = em.getTransaction();   
     tx.begin();   
     em.persist(object);   
     tx.commit();   
     em.close();   
    

    }

}
Main[/code]

[code]
view plaincopy to clipboardprint?
persistence

<?xml version=“1.0” encoding=“UTF-8”?>
<persistence version=“1.0” 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 http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name=“persistencia” >
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<class>persistencia.Associado</class>
<properties>
<property name=“toplink.jdbc.user” value=“postgres”/>
<property name=“toplink.jdbc.password” value=“postgres”/>
<property name=“toplink.jdbc.url” value=“jdbc:postgresql://localhost:5432/jpa”/>
<property name=“toplink.jdbc.driver” value=“org.postgresql.Driver”/>
</properties>
</persistence-unit>
</persistence>
persistence

<?xml version=“1.0” encoding=“UTF-8”?>
<persistence version=“1.0” 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 http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name=“persistencia” >
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<class>persistencia.Associado</class>
<properties>
<property name=“toplink.jdbc.user” value=“postgres”/>
<property name=“toplink.jdbc.password” value=“postgres”/>
<property name=“toplink.jdbc.url” value=“jdbc:postgresql://localhost:5432/jpa”/>
<property name=“toplink.jdbc.driver” value=“org.postgresql.Driver”/>
</properties>
</persistence-unit>
</persistence>[/code]

[quote]No meu projeto estao adicionados os seguintes JAR:

view plaincopy to clipboardprint?
PostgresSQL Drive
TopLink-essentials.jar
TopLink-essentials-agente.far[/quote]

O arquivo persistence.xml não foi encontrado, onde ele está?

Tente coloca-lo na pasta META-INF.

Ele esta dentro da pasta META-INF