Boa tarde ...

Estou tentando dar meus primeiros passos em persistência com JPA , mas estou 
esbarrando em um erro que não consigo resolver ...
O
estranho é que , se rodar o projeto pelo eclipse, funciona
perfeitamente . Se rodar pelo netbeans dá o erro . Infelizmente preciso
rodar pelo Netbeans . Segue abaixo os arquivos para analise :


===============
mensagem de erro :
===============
Exception in thread "main" javax.persistence.PersistenceException: No 
Persistence provider for EntityManager named rbpu
        at 
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:56)

        at 
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
        at telas.LoadAluno.main(LoadAluno.java:15)



============
persistence.xml
============
<?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="rbpu" transaction-type="RESOURCE_LOCAL">
  <provider>org.hibernate.ejb.HibernatePersistence</provider>
 
    <class>dominio.Alunos</class>

    <properties>
      <property name="hibernate.hbm2ddl.auto" value="none"/>
      <property name="hibernate.format_sql" value="true"/>
      <property name="hibernate.dialect" 
value="org.hibernate.dialect.MySQLDialect"/>

      <property name="hibernate.connection.driver_class" 
value="com.mysql.jdbc.Driver"/>
      <property name="hibernate.connection.url" 
value="jdbc:mysql://localhost:3306/controleescolar"/>

      <property name="hibernate.connection.username" value="root"/>
      <property name="hibernate.connection.password" value=""/>
      <property name="" value=""/>

    </properties>
  </persistence-unit>
</persistence>

=========
Alunos.java
=========
package dominio;

import javax.persistence.Column;
import javax.persistence.Entity;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;


@Entity
public class Alunos {

    @Id

        @GeneratedValue(strategy = GenerationType.IDENTITY)
        
        private int id_aluno;
        private String nome;
        private String nacionalidade;
        private String naturalidade;

        private String nascimento;
        private String cor;
        private String sexo;
        private String pai;
        private String mae;
        private String endereco;
        private String numero;

        private String complemento;
        private String bairro;
        private String cidade;
        private String uf;
        private String cep;
        private String telres;
        private String telcel;

        private String teltrab;
        private String contato;
    private String situacao;
    
    
    
    public int getId_aluno() {
        return id_aluno;
    }

   // public void setId_aluno(int id_aluno) {

   //     this.id_alunos = id_aluno;
   // }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getNacionalidade() {

        return nacionalidade;
    }

    public void setNacionalidade(String nacionalidade) {
        this.nacionalidade = nacionalidade;
    }

    public String getNaturalidade() {
        return naturalidade;

    }

    public void setNaturalidade(String naturalidade) {
        this.naturalidade = naturalidade;
    }

    public String getNascimento() {
        return nascimento;
    }

    public void setNascimento(String nascimento) {

        this.nascimento = nascimento;
    }

    public String getCor() {
        return cor;
    }

    public void setCor(String cor) {
        this.cor = cor;
    }

    public String getSexo() {

        return sexo;
    }

    public void setSexo(String sexo) {
        this.sexo = sexo;
    }

    public String getPai() {
        return pai;
    }

    public void setPai(String pai) {

        this.pai = pai;
    }

    public String getMae() {
        return mae;
    }

    public void setMae(String mae) {
        this.mae = mae;
    }

    public String getEndereco() {

        return endereco;
    }

    public void setEndereco(String endereco) {
        this.endereco = endereco;
    }

    public String getNumero() {
        return numero;
    }

    public void setNumero(String numero) {

        this.numero = numero;
    }

    public String getComplemento() {
        return complemento;
    }

    public void setComplemento(String complemento) {
        this.complemento = complemento;

    }

    public String getBairro() {
        return bairro;
    }

    public void setBairro(String bairro) {
        this.bairro = bairro;
    }

    public String getCidade() {
        return cidade;

    }

    public void setCidade(String cidade) {
        this.cidade = cidade;
    }

    public String getUf() {
        return uf;
    }

    public void setUf(String uf) {
        this.uf = uf;

    }

    public String getCep() {
        return cep;
    }

    public void setCep(String cep) {
        this.cep = cep;
    }

    public String getTelres() {
        return telres;

    }

    public void setTelres(String telres) {
        this.telres = telres;
    }

    public String getTelcel() {
        return telcel;
    }

    public void setTelcel(String telcel) {

        this.telcel = telcel;
    }

    public String getTeltrab() {
        return teltrab;
    }

    public void setTeltrab(String teltrab) {
        this.teltrab = teltrab;
    }

    public String getContato() {

        return contato;
    }

    public void setContato(String contato) {
        this.contato = contato;
    }

    public String getSituacao() {
        return situacao;
    }

    public void setSituacao(String situacao) {

        this.situacao = situacao;
    }
    
    @Override
    public String toString() {
        return getNome();
    }
    
    @Override
    public int hashCode() {
        return getId_aluno();

    }
}

e finalmente, a classe que deverá fazer a procura do aluno no banco de dados :

============
LoadAluno.java
============

package telas;

import dominio.Alunos;
import java.util.List;

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



public class LoadAluno {
    
    public static void main(String[] args) {

        EntityManagerFactory emf = 
Persistence.createEntityManagerFactory("rbpu");
        EntityManager em = emf.createEntityManager();
        
        // Codigo do aluno a ser localizado
        Integer codigo = 12;


        Query query = em.createQuery("from Alunos where id_alunos = :idParam");
        query.setParameter("idParam", codigo);
        List<Alunos> results = query.getResultList();
        

        for (Alunos a : results){
            System.out.println("======================");
            System.out.println(a.getId_aluno());
            System.out.println(a.getNome());
            System.out.println("======================");

        }
        
        em.close();
        emf.close();
        
    }

}


Mauricio C. de Magalhães
Skype Id : mcmagalh


      Novos endereços, o Yahoo! que você conhece. Crie um email novo com a sua 
cara @ymail.com ou @rocketmail.com.
http://br.new.mail.yahoo.com/addresses

Atrašyti