[英]Wildfly - How to startup bean before persistence is loaded?
I would like to execute some logic before Persistence Unit is loaded in Wildfly 8.0. 我想在将持久性单元加载到Wildfly 8.0中之前执行一些逻辑。 I have a structure like this: 我有这样的结构:
beans.jar contains entity beans with persistence.XML and session beans beans.jar包含具有persistence.XML的实体bean和会话bean
before-persistence-bean.jar contains one class: before-persistence-bean.jar包含一个类:
@Startup
@Singleton
public class BeforePersistenceServiceBean {
@PostConstruct
public void performOperations() {...}
}
In application.xml I have: 在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>
Now, after starting Wildfly I get error that: 现在,在启动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]
But BeforePersistenceServiceBean doesn't have dependency on Persistence Unit, what is going on here ? 但是BeforePersistenceServiceBean不依赖于Persistence Unit,这是怎么回事?
---EDIT--- - -编辑 - -
After failing to deploy this bean before persistence kicks off, I have used solution similar to described in CDI Extension for Flyway (ie using Hibernate Integrator API) 在持久性启动之前未能部署该bean之后,我使用了与CDI Extension for Flyway中所述类似的解决方案(即,使用Hibernate Integrator API)
Add a jboss-deployment-structure.xml
to the META-INF
directory if your EAR to indicate you want the subdeployments isolated . 如果您的EAR表示您希望隔离子 jboss-deployment-structure.xml
请将jboss-deployment-structure.xml
添加到META-INF
目录。
I would imagine the contents would look something like 我想其中的内容看起来像
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.