readthefuckingmanual.net

[SOLVED] javax.persistence.PersistenceException: No Persistence provider for EntityManager named

Error added: 2008-09-16T11:59:17Z

3 people waiting for the answer...

27 answers found.

Answer 1855 (56.0% helpful)

fOR ME THE PROBLEM WAS ON WHERE MY META-INF WAS IN...IT WAS NOT IN THE SRC ! I PLACED IT ON SRC THAN IT WORKED FINE.
Permalink

Answer 1674 (56.25% helpful)

If you use EclipseLink and you use Maven 2  remember you need the artifacts javax.persistence and eclipselink:

<dependency>
  <groupId>org.eclipse.persistence</groupId>
  <artifactId>javax.persistence</artifactId>
  <version>2.0.0</version>
</dependency>
    
<dependency>
  <groupId>org.eclipse.persistence</groupId>
  <artifactId>eclipselink</artifactId>
  <version>2.0.0</version>
</dependency>

Your persistence.xml should be placed in:

resources\META-INF\

For example, if you defined the persistence unit like this:

<persistence-unit name="myPU" transaction-type="RESOURCE_LOCAL">

You have to create with:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("myPU");
Permalink

Answer 1301 (44.444443% helpful)

If using Netbeans 6.8, the problem arose after I edited the PU in the persistence.xml file. This caused Netbeans to create two entitymanager references, one called entitymanager and the second called entitymanager1. 

Do a find for \"entitymanager1\" and if this is  your problem too then you will need to edit some files by hand (not in Netbeans remember to close the project in Netbeans first)

Go to the src\\name-of-your-project\\resources folder and find the properties file(s) mentioned in the search for entitymanager1 above. 

Open the files with notepad and edit. Find the line that says entityManager.persistenceUnit=
Make sure that what follows the equal sign is accurate for the name of your PU. Cut and paste from persistence.xml file if need be.

Next, edit the java files where the following line appears 

javax.persistence.Persistence.createEntityManagerFactory(\"\").createEntityManager()

In the quotations above should appear your PU as mentioned above.

Delete any reference to entitymanager1 you find.

This worked for me, but be careful editing. And good luck with it. It is worth persisting!
Permalink

Answer 1608 (44.444443% helpful)

name="CargaOrganigrama" transaction-type="RESOURCE_LOCAL"

And I'm calling EntityManagerFactory emf =
				javax.persistence.Persistence.createEntityManagerFactory("cargaOrganigrama");
Permalink

Answer 702 (53.846153% helpful)

Assuming you have one declared in persistence.xml, there are 2 common problems.
1. You don\'t have the hibernate-entitymanager jars.
2. The persistence.xml is in the wrong place. It needs to be in META-INF, but for me (using Netbeans 6), it had to be in src/conf/ not in web/META-INF/
I assume it gets copied to META-INF during build
Permalink

Answer 1176 (40.0% helpful)

[HACK] If using Spring, create a LocalContainerEntityManagerFactoryBean and set persistenceProviderClass property to your persistence provider - look for the contents of /META-INF/services/javax.persistence.spi.PersistenceProvider in the corresponding jar(for me it was hibernate-entitymanager.xx.jar).
Permalink

Answer 1273 (40.0% helpful)

in my case remember that it is persistence.xml not persistance.xml 
Permalink

Answer 1172 (37.5% helpful)

A solution that worked for me:

Using Hyperjaxb, which autogenerates a persistence-unit name if one is not supplied to it at runtime, can generate a name that exceeds a recognizable length.

Solution for me was to provide persistence-unit name to hyperjaxb for it to use in generated persistence.xml file.
Permalink

Answer 1465 (41.176468% helpful)

If you\'re trying to run your app from Eclipse and have your persistence.xml at src/main/resources check your build path. It may be excluding this folder.
Permalink

Answer 1648 (33.333332% helpful)

uninstall netbeans and install second time 
i m sure problem will bsoved
Permalink

Answer 1677 (33.333332% helpful)

I am using netbeans 6.9. The solution that i found was to change Persistence library from TopLink to Hibernate. 
This can be done after opening persistence.xml from netbeans, and congiguring it properly.(it's very easy) 
Then you have to add hibernate JPA to project's libraries.
After these thinks, it works!
Permalink

Answer 1856 (33.333332% helpful)

fOR ME THE PROBLEM WAS ON WHERE MY META-INF WAS IN...IT WAS NOT IN THE SRC ! I PLACED IT ON SRC THAN IT WORKED FINE.
Permalink

Answer 1570 (35.294117% helpful)

Format your pc
Permalink

Answer 1713 (25.0% helpful)

put the persistence.xml in src directory
Permalink

Answer 995 (0.0% helpful)

Try to check that the name of the PersistenceUnitName in the source code matches the one in the persistence.xml
Permalink

Answer 1204 (0.0% helpful)

Put persistence.xml in WEB-INF\\classes\\META-INF
Permalink

Answer 1361 (0.0% helpful)

In addition to Answer 1, in your persistence.xml, below your <persistence-unit ...> add \"<provider>org.hibernate.ejb.HibernatePersistence</provider>\" or the provider of your choice.
Permalink

Answer 1395 (0.0% helpful)

the persistence.xml must be inside of src directory ;-(
Permalink

Answer 1537 (0.0% helpful)

yhil
Permalink

Answer 1564 (0.0% helpful)

fdfgdfgd
Permalink

Answer 1831 (0.0% helpful)

you need to add hibernate or toplink jar into Lib.
check it.
if you are building EJB3 project,it will happen!
Permalink

Answer 1302 (0.0% helpful)

In addition to Answer 8, needed to say that PU means the \"persistence-unit name\" which is found in the persistence.xml file
Permalink

Answer 1445 (0.0% helpful)

For me, \'twas the location of the persistence.xml.
Confusion cleared up here : http://javahowto.blogspot.com/2007/06/where-to-put-persistencexml-in-web-app.html
Permalink

Answer 1488 (0.0% helpful)

and don\'t think you can call it something else than persistence.xml, like for instance testPersistence.xml :)
Permalink

Answer 1551 (0.0% helpful)

One way this exception can occur is when you have persistence.jar on your classpath but not the JPA provider jar.  Make sure you have both persistence.jar and eclipselink.jar on your classpath.
Permalink

Answer 1552 (0.0% helpful)

One way this exception can occur is when you have persistence.jar on your classpath but not the JPA provider jar.  Make sure you have both persistence.jar and eclipselink.jar on your classpath.
Permalink

Answer 1830 (0.0% helpful)

you need to add hibernate or toplink jar into Lib.
check it.
if you are building EJB3 project,it will happen!
Permalink

Add an answer/solution

If you know the answer, please add your own solution below.
If you don't know, but find out later, please come back and share your answer - there will be other people struggling with this too.


Please enter 61948 here

If you want to be notified via email when this is solved, enter your email address here: