简体   繁体   中英

No Persistence provider for EntityManager named MyBuzzPersistence

My JPA project runs fine on 32 bit windows 7 with 32 bit eclipse IDE but the same does not work with 64 bit Windows 8 with 32 bit eclipse IDE. In this project I am connecting to MS-Access by creating "User DSN" (named MyBuzzDB ). For 64 bit OS, I have created User DSN in its 32 bit ODBC dialogue.

I do have all JARs in my project as well.

Any help would be highly appreciated.

Here is my 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="MyBuzzPersistence">
    <provider>oracle.toplink.essentials.PersistenceProvider</provider>

    <class>com.myBuzz.entity.AuthenticateEntity</class>
    <properties>

    <property name="toplink.jdbc.url" value="jdbc:odbc:MyBuzzDB" />
    <property name="toplink.jdbc.user" value="" />
    <property name="toplink.jdbc.driver" value="sun.jdbc.odbc.JdbcOdbcDriver" />
    <property name="toplink.jdbc.password" value="" />

    </properties>
</persistence-unit>

</persistence>


Stack trace is :

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named MyBuzzPersistence
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at com.myBuzz.service.AuthenticationService.authenticateUser(AuthenticationService.java:17)
at com.myBuzz.manager.AuthenticationManager.authenticateUser(AuthenticationManager.java:16)
at com.myBuzz.test.DBTest.main(DBTest.java:21)

The persistence.xml is not in the correct location...

You will need to move the persistence.xml file to an appropriate location, that is add the META-INF/persistence.xml file to the root of a source folder.

The following is from the JPA spec :

A persistence.xml file defines a persistence unit. The persistence.xml file is 
located in the META-INF directory of the root of the persistence unit. 

The root of the persistence unit is the key here.

If you are a non-Java EE app

The jar file or directory whose META-INF directory contains the persistence.xml 
file is termed the root of the persistence unit.

If you are in a Java EE app , the following are valid

In Java EE environments, the root of a persistence unit must be one of the following:
• an EJB-JAR file
• the WEB-INF/classes directory of a WAR file[80]
• a jar file in the WEB-INF/lib directory of a WAR file
• a jar file in the EAR library directory
• an application client jar file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM