No persistence provider found with JBoss AS 7

时光总嘲笑我的痴心妄想 提交于 2020-01-15 08:20:21

问题


I've just migrated from Tomcat to JBoss AS 7. So, I configured Mysql datasource in JBoss (adding module.xml with associated Jar, adding driver bloc into standalone.xml and configuring datasource through JBoss interface.

No errors when deploying but impossible to get an entityManager (JPA with Hibernate in background).

Indeed, when this code is executed:

Persistence.createEntityManagerFactory("RoomManagement");

I obtain this error :

javax.persistence.PersistenceException: No Persistence provider for EntityManager named RoomManagement javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69) javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)

Very strange because I well verified that my persistence.xml does take place into War at WEB-INF/classes/META-INF directory.

My persistence.xml looks like as follow :

<?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> 

Did I make a mistake or forgot to specify something ?


回答1:


Remove the hibernate jar from WEB-INF/lib. JBoss has that bundled, so if you have it on the classpath it probably confuses the classloader.



来源:https://stackoverflow.com/questions/10080004/no-persistence-provider-found-with-jboss-as-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!