我得到了與Maven(快速啓動原型)創建了一個簡單的Java項目JPA:配置持續性提供
我想配置Drools的會議JPA的持久性(代碼來自Drools的文檔)
我加滴料的持久性,JPA,Bitronix事務管理和com.h2database依賴於我的pom.xml
我創建了一個META-I NF文件夾作爲我的Eclipse項目中的源文件夾「src/META-INF」
我在那裏添加了persistence.xml和jndi.properties文件。
以我測試用例我已經以下代碼:
[...] EntityManagerFactory的電動勢= Persistence.createEntityManagerFactory( 「org.drools.persistence.jpa」); [...]
運行測試時,我得到以下異常:
javax.persistence.PersistenceException:否 EntityManager的命名org.drools.persistence.jpa持久性提供者在 javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69) 在 javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) 在com.sample.MyTest.testJPA(MyTest.java:112)
我比較肯定的,那這裏還有一些毛病我創建的META-INF或persistence.xml中(見下文)的方式。有什麼建議麼?
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
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
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
<persistence-unit name="org.drools.persistence.jpa" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/testDatasource</jta-data-source>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceEventInfo</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.max_fetch_depth" value="3" />
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.connection.autocommit" value="true" />
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />
</properties>
</persistence-unit>
</persistence>
謝謝! hibernate-entitymanager丟失了。 – Alex