1

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)
cmd
  • 11,622
  • 7
  • 51
  • 61
suchakd
  • 21
  • 2
  • It sounds like persistence.xml is not in the correct location, it is in META-INF ? – Koitoer Feb 11 '14 at 17:37
  • This is a duplicate of http://stackoverflow.com/questions/19322827/null-after-persistence-createentitymanagerfactorypersistence-unit-name/19327322#19327322 – cmd Feb 11 '14 at 18:30
  • Most of the time we will get this error for other Errors as well .if your persistence.xml is in your META-INF then post the full stacktrace. So that we can help you. – Sathesh S Feb 11 '14 at 18:56
  • @Koitoer : My persistence.xml is in META-INF only. – suchakd Feb 22 '14 at 08:24
  • @SatheshS : The above mentioned stack trace is the full stack trace. – suchakd Feb 22 '14 at 08:25

1 Answers1

0

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
cmd
  • 11,622
  • 7
  • 51
  • 61