我遇到了JBoss 7.02.Final的問題。我正在從JBoss5.1GA移植一個項目,並且(在支持EE6的查找中有相當數量的重寫)我在註冊classpath上的Eclipselink時遇到了問題。我搜索了四周,我看到幾個帖子說這個問題已經解決,但我似乎無法找到一個工作的例子。JBoss7和Eclipselink,沒有EntityManager的持久性提供者
由於我是EE6開發的新手,所以我做錯事的可能性非常高。
耳朵被構建爲以下
- ProductionEE6
./lib/eclipselink2.*.jar
./lib/javax.persistence.jar
. . .
ProductionEJB.jar
. . .
Production.war
我的persistence.xml是:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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 persistence_2_0.xsd">
<persistence-unit name="production" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>java:/ProductionDS</non-jta-data-source>
<class><!-- entities --></class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
<property name="eclipselink.target-server" value="JBoss"/>
<!-- A few other properties here -->
</properties>
</persistence-unit>
</persistence>
一切靴子了罰款,我看到的數據源,通過我得到的安全性(通過一個自定義DatabaseModule,所以我的數據源一定很好),當我最終打電話給一個EJB時,我看到以下錯誤:
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named production
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at com.danielbchapman.production.entity.DelegateInstance.getEm(DelegateInstance.java:67) [ProductionEJB.jar:]
at com.danielbchapman.production.entity.EntityInstance.getEm(EntityInstance.java:39) [ProductionEJB.jar:]
at com.danielbchapman.production.beans.OptionsDao.<init>(OptionsDao.java:20) [ProductionEJB.jar:]
... 94 more
對此,我沒有使用JTA數據源,因此我一直在手動處理事務。這呼喚,就是「DelegateInstance」上面用下面的代碼:(這裏persistenceUnitId是「生產」在這種情況下)
/**
* @return an instance of the entity manager if it isn't there.
*/
public EntityManager getEm()
{
if(manager == null)
{
manager = Persistence.createEntityManagerFactory(getPersistenceUnitId())
.createEntityManager();
}
return manager;
}
我什麼擔心最多的是看到了這個堆棧上: [ hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]很明顯,我沒有正確加載EclipseLink。我在這裏沒有想法,所以如果有人能幫助我,我會非常感激。
謝謝約翰,我會給這個建築一個鏡頭。 –
對不起,花了這麼長時間來測試,但是,是的,現在Eclipselink 2.4在JBoss 7.1.1中運行良好。 –