我的JPA項目在32位eclipse IDE的32位Windows 7上運行良好,但同樣不適用於帶有32位eclipse IDE的64位Windows 8。在這個項目中,我通過創建「用戶DSN」(名爲MyBuzzDB)連接到MS-Access。對於64位操作系統,我在其32位ODBC對話中創建了 用戶DSN。No EntityManager的持久性提供程序名爲MyBuzzPersistence
我的項目中也有所有的JAR。
任何幫助將不勝感激。
這裏是我的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>
堆棧跟蹤是:
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)
這聽起來像的persistence.xml是不在正確的位置,它在META-INF中? – Koitoer
這是一個重複的http://stackoverflow.com/questions/19322827/null-after-persistence-createentitymanagerfactorypersistence-unit-name/19327322#19327322 – cmd
大多數時候我們會得到這個錯誤的其他錯誤以及.if你的persistence.xml在你的META-INF中,然後發佈完整的stacktrace。所以我們可以幫助你。 –