持续范围失败?
问题描述:
我也照做按规格搜索8.2.2持久单元的范围, 之一,但它引发异常像持续范围失败?
15:08:09,956 WARNING [FileZippedJarVisitor] Unable to find file (ignored): file:entities1.jar
java.io.FileNotFoundException: entities1.jar (The system cannot find the file specified)
...similarly other one too
这里失败的原因是耳朵的结构:
|-ear--
|-lib--|... some libs ...
| |--my-persistence-xml.jar
|--entities1.jar
|--entities2.jar
|-ejb-1.jar
|-web-1.war
这里是持久性:
<persistence-unit name="pu" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/mypu</jta-data-source>
<jar-file>entities1.jar</jar-file>
<jar-file>entities2.jar</jar-file>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
答
persistence.xml
应放置在您的0 META-INF
文件夹模块。在这种情况下,您可以使用persistence.xml
而不使用<jar-file>
。所有实体将自动注册。
如果你想使用<jar-file>
那么路径应该是
<jar-file>../../entities1.jar</jar-file>
<jar-file>../../entities2.jar</jar-file>
拿什么my-persistence-xml.jar
。它是jar
或xml
?
感谢您的回复。 my-persistence-xml.jar仅包含META-INF下的持久性单元,但所有实体都可用于entities1.jar和entities2.jar。 – Moorthy
它也应该有'ejb-jar.xml'在META-INF – Ilya
我将my-persistence-xml.jar从lib移到耳朵级别,但仍然不能识别为有效路径。 – Moorthy