Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Hibernate Error using JPA

Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am trying the examples in the book Persistence with Hibernate and I am getting the following error.

javax.persistence.PersistenceException: No Persistence provider for EntityManager named messages
at javax.persistence.Persistence.createEntityManagerFactory(
at javax.persistence.Persistence.createEntityManagerFactory(

My code...

public boolean addMessage(MessageWithAnnotations message) {
EntityManagerFactory emf =
EntityManager em = emf.createEntityManager();
EntityTransaction et = em.getTransaction();
MessageWithAnnotations m = new MessageWithAnnotations("Jpa Persistence");
m.setNextMessage(new MessageWithAnnotations("Jpa Next Persistence"));
return true;

I am not sure what is causing this. I have hibernate-entity manager in build path. I am using Eclipse to run this test. Please help.

Annnotated class

@Table(name = "MESSAGES")
public class MessageWithAnnotations {

@Column(name = "MESSAGE_ID")
private Integer id;

@Column(name = "MESSAGE_TEXT")
private String text;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "NEXT_MESSAGE_ID")
private MessageWithAnnotations nextMessage;

public Integer getId() {
return id;

public void setId(Integer id) { = id;

public String getText() {
return text;

public void setText(String text) {
this.text = text;

public MessageWithAnnotations getNextMessage() {
return nextMessage;

public void setNextMessage(MessageWithAnnotations nextMessage) {
this.nextMessage = nextMessage;

private MessageWithAnnotations() {}

public MessageWithAnnotations(String text) {
this.text = text;
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic