我想在Wildfly 8.0中加载Persistence Unit之前执行一些逻辑。 我有这样的结构:
beans.jar包含具有persistence.XML和会话bean的实体bean
before-persistence-bean.jar包含一个类:
@Startup
@Singleton
public class BeforePersistenceServiceBean {
@PostConstruct
public void performOperations() {...}
}
在application.xml中我有:
<initialize-in-order>true</initialize-in-order>
<module>
<ejb>before-persistence-bean.jar</ejb>
</module>
<module>
<ejb>beans.jar</ejb>
</module>
<module>
<web>
<web-uri>xxx.war</web-uri>
<context-root>/xxx</context-root>
</web>
</module>
现在,在启动Wildfly后,我得到错误:
service jboss.persistenceunit."xxx.ear/beans.jar#pu_name" (missing) dependents:
[service jboss.deployment.subunit."xxx.ear"."before-persistence
bean.jar".component.BeforePersistenceServiceBean.START]
但是BeforePersistenceServiceBean没有依赖Persistence Unit,这里发生了什么?
--- --- EDIT
在持久性开始之前未能部署此bean之后,我使用了解决方案 类似于CDI Extension for Flyway中描述的(即使用Hibernate Integrator API)
答案 0 :(得分:0)
如果您的EAR表明您想要subdeployments isolated,请在jboss-deployment-structure.xml
目录中添加META-INF
。
我认为内容看起来像
<subsystem xmlns="urn:jboss:domain:ee:1.0" >
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<sub-deployment name="xxx.war">
<dependencies>
<module name="deployment.xxx.ear.beans.jar" />
</dependencies>
</sub-deployment>
</subsystem>