我剛從Tomcat遷移到JBoss AS 7. 因此,我在JBoss中配置了Mysql數據源(將module.xml添加到相關Jar中,將驅動程序塊添加到standalone.xml中並配置通過JBoss的接口數據源在JBoss AS 7中找不到持久性提供者
沒有錯誤部署,但不可能得到一個EntityManager(JPA與Hibernate背景)當
事實上,當執行該代碼:。
Persistence.createEntityManagerFactory("RoomManagement");
我得到這個埃羅R:
javax.persistence.PersistenceException:否 EntityManager的持久性提供者名爲RoomManagement javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69) javax.persistence.Persistence.createEntityManagerFactory(Persistence.java: 47)
很奇怪,因爲我很好地證實了我的persistence.xml確實發生在WAR-WEB-INF/classes/META-INF目錄中。
我的persistence.xml看起來像如下:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="RoomManagement" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/MySqlDS</jta-data-source>
<class>com.parisdescartes.roommanagement.domain.entities.Address</class>
<class>com.parisdescartes.roommanagement.domain.entities.Building</class>
<class>com.parisdescartes.roommanagement.domain.entities.Civility</class>
<class>com.parisdescartes.roommanagement.domain.entities.EventType</class>
<class>com.parisdescartes.roommanagement.domain.entities.Job</class>
<class>com.parisdescartes.roommanagement.domain.entities.Reservation</class>
<class>com.parisdescartes.roommanagement.domain.entities.Room</class>
<class>com.parisdescartes.roommanagement.domain.entities.RoomType</class>
<class>com.parisdescartes.roommanagement.domain.entities.Tool</class>
<class>com.parisdescartes.roommanagement.domain.entities.User</class>
<class>com.parisdescartes.roommanagement.domain.entities.UserDetail</class>
<class>com.parisdescartes.roommanagement.domain.entities.Schedule</class>
<properties>
<property name="hibernate.connection.autocommit" value="true" />
<property name="hibernate.archive.autodetection" value="class"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
</properties>
</persistence-unit>
</persistence>
難道我犯了一個錯誤或忘了指定的東西嗎?
非常感謝!這正是:) – Mik378 2012-04-09 22:20:58