Aplicativo Desktop com hibernate não funciona. RESOLVIDO

Pessoal, pequei um exemplo na net e tentei rodar aqui. Mas nao estou conseguindo. Na hora de salvar as informaçoes no banco de dados, esta dando
um erro que eu procurei no google mas ate agora nao descobri!!

Codigo do 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="JPATutorialPU" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>jpatutorial.Address</class>
    <properties>
      <property name="hibernate.connection.username" value="test_mgr"/>
      <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
      <property name="hibernate.connection.password" value="123456"/>
      <property name="hibernate.connection.url" value="jdbc:postgresql://127.0.0.1:5432/postgres"/>
      <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
      <property name="hibernate.hbm2ddl.auto" value="update"/>
    </properties>
  </persistence-unit>
</persistence>

Codigo do Main

/*
 * MainUI.java
 *
 * Created on 18. Oktober 2007, 22:08
 */
package jpatutorial;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author  Marcel Gascoyne
 */
public class MainUI extends JFrame {

    /** Creates new form MainUI */
    public MainUI() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        customerNoLabel = new javax.swing.JLabel();
        lastnameLabel = new javax.swing.JLabel();
        firstnameLabel = new javax.swing.JLabel();
        streetLabel = new javax.swing.JLabel();
        postcodeLabel = new javax.swing.JLabel();
        cityLabel = new javax.swing.JLabel();
        customerNoText = new javax.swing.JTextField();
        lastnameText = new javax.swing.JTextField();
        firstnameText = new javax.swing.JTextField();
        streetText = new javax.swing.JTextField();
        postcodeText = new javax.swing.JTextField();
        cityText = new javax.swing.JTextField();
        loadButton = new javax.swing.JButton();
        saveButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        customerNoLabel.setText("Customer No.");

        lastnameLabel.setText("Lastname");

        firstnameLabel.setText("Firstname");

        streetLabel.setText("Street");

        postcodeLabel.setText("Postcode");

        cityLabel.setText("City");

        customerNoText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                customerNoTextActionPerformed(evt);
            }
        });

        loadButton.setText("Load");
        loadButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loadButtonActionPerformed(evt);
            }
        });

        saveButton.setText("Save");
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(customerNoLabel)
                    .addComponent(lastnameLabel)
                    .addComponent(firstnameLabel)
                    .addComponent(streetLabel)
                    .addComponent(postcodeLabel)
                    .addComponent(cityLabel))
                .addGap(17, 17, 17)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(loadButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(saveButton))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(customerNoText)
                        .addComponent(lastnameText, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                        .addComponent(firstnameText)
                        .addComponent(streetText)
                        .addComponent(cityText)
                        .addComponent(postcodeText)))
                .addContainerGap(152, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(customerNoLabel)
                    .addComponent(customerNoText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lastnameLabel)
                    .addComponent(lastnameText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(firstnameLabel, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(firstnameText, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(streetText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(streetLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(postcodeLabel)
                    .addComponent(postcodeText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cityLabel)
                    .addComponent(cityText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(19, 19, 19)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(loadButton)
                    .addComponent(saveButton))
                .addContainerGap(40, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

  private void loadButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           


      EntityManagerFactory emf = Persistence.createEntityManagerFactory(
              "persistence.xml");
      EntityManager em = emf.createEntityManager();
      em.getTransaction().begin();

      String customerNo = JOptionPane.showInputDialog(null, "Enter customer number", "Input", JOptionPane.QUESTION_MESSAGE);

      try {
          Query query = em.createQuery("SELECT a FROM Address a WHERE a.customerNo = :customerNo");

          query.setParameter("customerNo", customerNo);

          Address address = (Address) query.getSingleResult();

          customerNoText.setText(address.getCustomerNo());
          lastnameText.setText(address.getLastname());
          firstnameText.setText(address.getFirstname());
          streetText.setText(address.getStreet());
          postcodeText.setText(address.getPostcode());
          cityText.setText(address.getCity());

      } catch (Exception e) {
          System.out.println(e.getMessage());
          em.getTransaction().rollback();
      } finally {
          em.close();
      }
  }                                          

  private void saveButtonActionPerformed(ActionEvent evt) {                                           

      Address address = new Address();
      address.setCustomerNo(customerNoText.getText());
      address.setLastname(lastnameText.getText());
      address.setFirstname(firstnameText.getText());
      address.setStreet(streetText.getText());
      address.setPostcode(postcodeText.getText());
      address.setCity(cityText.getText());

      EntityManagerFactory emf = Persistence.createEntityManagerFactory(
              "persistence.xml");
      EntityManager em = emf.createEntityManager();
      em.getTransaction().begin();

      try {
          em.persist(address);
          em.getTransaction().commit();
      } catch (Exception e) {
          System.out.println(e.getMessage());
          em.getTransaction().rollback();
      } finally {
          em.close();
      }
  }                                          

  private void customerNoTextActionPerformed(java.awt.event.ActionEvent evt) {                                               
      // TODO add your handling code here:
  }                                              

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new MainUI().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JLabel cityLabel;
    private javax.swing.JTextField cityText;
    private javax.swing.JLabel customerNoLabel;
    private javax.swing.JTextField customerNoText;
    private javax.swing.JLabel firstnameLabel;
    private javax.swing.JTextField firstnameText;
    private javax.swing.JLabel lastnameLabel;
    private javax.swing.JTextField lastnameText;
    private javax.swing.JButton loadButton;
    private javax.swing.JLabel postcodeLabel;
    private javax.swing.JTextField postcodeText;
    private javax.swing.JButton saveButton;
    private javax.swing.JLabel streetLabel;
    private javax.swing.JTextField streetText;
    // End of variables declaration                   
}

Os gets e sets

/*
 * Address.java
 *
 * Created on 18. Oktober 2007, 23:32
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package jpatutorial;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 * Entity class Address
 * 
 * 
 * @author Marcel Gascoyne
 */
@Entity
public class Address implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String customerNo;
    private String lastname;
    private String firstname;
    private String street;
    private String postcode;
    private String city;

    /**
     * Creates a new instance of Address
     */
    public Address() {
    }

    /**
     * Gets the id of this Address.
     *
     * @return the id
     */
    public Long getId() {
        return this.id;
    }

    /**
     * Sets the id of this Address to the specified value.
     *
     * @param id the new id
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * Returns a hash code value for the object.  This implementation computes
     * a hash code value based on the id fields in this object.
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (this.getId() != null ? this.getId().hashCode() : 0);
        return hash;
    }

    /**
     * Determines whether another object is equal to this Address.  The result is
     * <code>true</code> if and only if the argument is not null and is a Address object that
     * has the same id field values as this object.
     *
     * @param object the reference object with which to compare
     * @return <code>true</code> if this object is the same as the argument;
     * <code>false</code> otherwise.
     */
    @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 Address)) {
            return false;
        }
        Address other = (Address) object;
        if (this.getId() != other.getId() && (this.getId() == null || !this.getId().equals(other.getId()))) {
            return false;
        }
        return true;
    }

    /**
     * Returns a string representation of the object.  This implementation constructs
     * that representation based on the id fields.
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "jpatutorial.NewEntity[id=" + getId() + "]";
    }

    public String getCustomerNo() {
        return customerNo;
    }

    public void setCustomerNo(String customerNo) {
        this.customerNo = customerNo;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getPostcode() {
        return postcode;
    }

    public void setPostcode(String postcode) {
        this.postcode = postcode;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }
}

Quem souber por favor, me ajude!

Obrigado!

Posta o erro q fica mais fácil da galera ajudar…

[]'s

Então, para a gente te ajudar, devemos pegar todos estes arquivos, compilar e tentar reproduzir a mensagem de erro que vc não conseguiu descobrir o significado no google?

Não seria mais facil fornecer o erro também?

Foi mal…esqueci de colocar o erro…

init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\Administrator\My Documents\NetBeansProjects\JPATutorial\build\classes
compile-single:
run-single:
03/03/2009 14:04:42 org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.1.GA
03/03/2009 14:04:42 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.5
03/03/2009 14:04:42 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
03/03/2009 14:04:42 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
03/03/2009 14:04:42 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
03/03/2009 14:04:42 org.hibernate.ejb.Version <clinit>
INFO: Hibernate EntityManager 3.3.2.GA
03/03/2009 14:04:42 org.hibernate.ejb.Ejb3Configuration configure
INFO: Could not find any META-INF/persistence.xml file in the classpath
Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: No Persistence provider for EntityManager named persistence.xml
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
        at jpatutorial.MainUI.loadButtonActionPerformed(MainUI.java:153)
        at jpatutorial.MainUI.access$100(MainUI.java:21)
        at jpatutorial.MainUI$2.actionPerformed(MainUI.java:74)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
        at java.awt.Component.processMouseEvent(Component.java:6216)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
        at java.awt.Component.processEvent(Component.java:5981)
        at java.awt.Container.processEvent(Container.java:2041)
        at java.awt.Component.dispatchEventImpl(Component.java:4583)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Component.dispatchEvent(Component.java:4413)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)
        at java.awt.Container.dispatchEventImpl(Container.java:2085)
        at java.awt.Window.dispatchEventImpl(Window.java:2475)
        at java.awt.Component.dispatchEvent(Component.java:4413)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

No seu código main, onde vc está utilizando:

EntityManagerFactory emf = Persistence.createEntityManagerFactory( "persistence.xml");

Troca pra:

EntityManagerFactory emf = Persistence.createEntityManagerFactory( "JPATutorialPU");

E faz o teste aih…

[]'s

Que coisa de loco…nao é que funcionou? rsrs
N acredito que a anta aqui nao viu isso…afff…mas paciencia, estou começando a agora a usar Java e Hibernate…
Achei estranho uma coisa, no serviços no netbeans, quando eu peço para monstrar as tabelas que foi criada, ele nao mostra. Mas eu entro no postegres e vejo a tabela que foi criada. Normal isso?
Pessoal, obrigado pela força!

Abraços!!

Bom que funcionou…

Eu nem entendo muito do NB… quase nem uso… mas se aparece no post é pq tah lah…

Coloca RESOLVIDO lah no título do tópico… e qlq coisa tamu por aih!!!

[]'ss