This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes javax.persistence.PersistenceException: No Persistence provider for EntityManager Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "javax.persistence.PersistenceException: No Persistence provider for EntityManager" Watch "javax.persistence.PersistenceException: No Persistence provider for EntityManager" New topic
Author

javax.persistence.PersistenceException: No Persistence provider for EntityManager

Tim Sangster
Greenhorn

Joined: Mar 27, 2011
Posts: 12
Hello,

I made a site with jsp's and servlets. Using a model which was saved using arraylists.
Than I persisted this model, using a Main class I tested all the methods I created.
Now I need to use this persisted model in my site.
But,
I seemed to have forgotten some of the links or made some wrongs one.
Because whenever I go to the any second page of my site and the servlet gets a request, it crashes.
This is because it try's getInstance() of my db which creates an entitymaneger.
It crashes on this line:
emf = Persistence.createEntityManagerFactory("BackPackPersistencyModelPU");
This is the full error:


This is my persistence.xml:



Do I have to put my xml somewhere in the web project? I tried various places.
Right now I simple have the jar of the model in my library of the web project.
I have put my entire project in dropbox just in case I didn't include enough information,
this is the public link: http://dl.dropbox.com/u/16098795/BackPackManagerPersisted.war

Any help is GREATLY appreciated!
Thanks in advance!
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Somewhere you need to make the EntityManagerFactory and subsequent EntityManager available within the web context.
eg http://javanotepad.blogspot.com/2007/05/jpa-entitymanagerfactory-in-web.html
(I haven't read all of that article, I hope it says everything I want it to ;) )
Tim Sangster
Greenhorn

Joined: Mar 27, 2011
Posts: 12
David O'Meara wrote:Somewhere you need to make the EntityManagerFactory and subsequent EntityManager available within the web context.
eg http://javanotepad.blogspot.com/2007/05/jpa-entitymanagerfactory-in-web.html
(I haven't read all of that article, I hope it says everything I want it to ;) )

I'm trying to implement this but I create my entity manager in my model and the contextlistener needs to be in the web project.
I don't really get how to link those two.
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
What version of Glassfish are you using? The latest version using EclipseLink not TopLink Essentials.

Try removing the <provider> tag, you may not have TopLink Essentials on the classpath.


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: javax.persistence.PersistenceException: No Persistence provider for EntityManager