未加载JPA persistence.xml

时间:2012-04-03 03:33:42

标签: jpa

使用glassfish,我的persistence.xml没有被加载。

my.ear
    META-INF/persistence.xml
    lib/entities.jar <!-- no persistence.xml here -->

persistence.xml包含

<persistence 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_2_0.xsd"
             version="2.0">
  <persistence-unit name="xxxPU" transaction-type="JTA">
    <jta-data-source>jdbc/xxxDS</jta-data-source>
    <jar-file>lib/entities.jar</jar-file>
  </persistence-unit>
</persistence>

成功部署但是,我得到了。

Unable to retrieve EntityManagerFactory for unitName xxxPU

感谢。

1 个答案:

答案 0 :(得分:1)

我会尝试创建一个包含persistence.xml文件的.jar文件。然后将jar文件放在lib文件夹中。更多信息here