我正在尝试使用嵌入的OpenEJB作为环境与Arquillian进行集成测试,但是由于缺少persistence.xml,部署失败。
它正在多模块Maven项目的模块(“服务”)中运行。该模块作为EJB-Jar(“ services.jar”)部署在EAR(“ services-ear.ear”)中。同样在EAR中,我将项目的另一个模块(“数据”)的jar(“ data-1.0-SNAPSHOT.jar”)作为库包含在内。后一个模块将实体pojos和DAO保存为EJB。所有的DAO都有一个EntityManager,它引用在/data-1.0-SNAPSHOT.jar中的/META-INF/persistence.xml中声明的持久性单元。因此,EAR中的结构为:
ear
|- services.jar
|- /lib/data-1.0-SNAPSHOT.jar
|- ...
当我建立部署耳朵以验证这些组件确实在存档中时,该结构即被打印出来。 当我运行集成测试时,出现OpenEJB(“ 15:45:48.345 [LogStreamAsync.Thread] INFO OpenEJB.server-Ready!”),并且构建和部署了归档文件。 OpenEJB在“ data-1.0-SNAPSHOT.jar”中找到EJB,并开始部署它们。但是,它随后无法在同一jar中找到persistence.xml。我已经验证了persistence.xml在jar中。对于每个EJB,我得到的消息都是相同的:
...
15:56:42.167 [LogStreamAsync.Thread] ERROR OpenEJB.startup.validation - FAIL ... PlatformDaoImpl: A persistence unit must be defined via META-INF/persistence.xml to satisfy @PersistenceContext ref "manager" to unit "". An example of a suitable persistence.xml might be:<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"><persistence-unit name=""><jta-data-source>java:openejb/Resource/myDataSource</jta-data-source><non-jta-data-source>java:openejb/Resource/myUnmanagedDataSource</non-jta-data-source><properties><property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/></properties></persistence-unit></persistence>
15:56:42.167 [LogStreamAsync.Thread] ERROR OpenEJB.startup.validation - FAIL ... DefaultThreatResponseStatusDaoImpl: A persistence unit must be defined via META-INF/persistence.xml to satisfy @PersistenceContext ref "manager" to unit "". An example of a suitable persistence.xml might be:<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"><persistence-unit name=""><jta-data-source>java:openejb/Resource/myDataSource</jta-data-source><non-jta-data-source>java:openejb/Resource/myUnmanagedDataSource</non-jta-data-source><properties><property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/></properties></persistence-unit></persistence>
15:56:42.167 [LogStreamAsync.Thread] ERROR OpenEJB.startup.validation - FAIL ... DataSourceDaoImpl: A persistence unit must be defined via META-INF/persistence.xml to satisfy @PersistenceContext ref "manager" to unit "". An example of a suitable persistence.xml might be:<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"><persistence-unit name=""><jta-data-source>java:openejb/Resource/myDataSource</jta-data-source><non-jta-data-source>java:openejb/Resource/myUnmanagedDataSource</non-jta-data-source><properties><property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/></properties></persistence-unit></persistence>
15:56:42.167 [LogStreamAsync.Thread] ERROR OpenEJB.startup.validation - FAIL ... TechnologyDaoImpl: A persistence unit must be defined via META-INF/persistence.xml to satisfy @PersistenceContext ref "manager" to unit "". An example of a suitable persistence.xml might be:<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"><persistence-unit name=""><jta-data-source>java:openejb/Resource/myDataSource</jta-data-source><non-jta-data-source>java:openejb/Resource/myUnmanagedDataSource</non-jta-data-source><properties><property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/></properties></persistence-unit></persistence>
15:56:42.167 [LogStreamAsync.Thread] ERROR OpenEJB.startup.validation - FAIL ... ear-scoped-cdi-beans_services-ear: A persistence unit must be defined via META-INF/persistence.xml to satisfy @PersistenceContext ref "manager" to unit "". An example of a suitable persistence.xml might be:<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"><persistence-unit name=""><jta-data-source>java:openejb/Resource/myDataSource</jta-data-source><non-jta-data-source>java:openejb/Resource/myUnmanagedDataSource</non-jta-data-source><properties><property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/></properties></persistence-unit></persistence>
15:56:42.167 [LogStreamAsync.Thread] ERROR OpenEJB.startup.validation - Invalid EjbModule(name=ear-scoped-cdi-beans_services-ear, path=ear-scoped-cdi-beans_services-ear)
...
我想念什么?