Reputation: 11
I would like to execute some logic before Persistence Unit is loaded in Wildfly 8.0. I have a structure like this:
beans.jar contains entity beans with persistence.XML and session beans
before-persistence-bean.jar contains one class:
@Startup
@Singleton
public class BeforePersistenceServiceBean {
@PostConstruct
public void performOperations() {...}
}
In application.xml I have:
<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:
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 ?
---EDIT---
After failing to deploy this bean before persistence kicks off, I have used solution similar to described in CDI Extension for Flyway (i.e. using Hibernate Integrator API)
Upvotes: 1
Views: 2697
Reputation: 17790
Add a jboss-deployment-structure.xml
to the META-INF
directory if your EAR to indicate you want the subdeployments isolated.
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>
Upvotes: 1