<div dir="ltr"><div>Hello devs,<br></div><div><div><br>I have a wildfly war application at hands, which depends on a jar which starts its own JPA persistence container with Spring. This jar has its own `persistence.xml`, with only one persistence unit.<br>
In the embedded jar, since there is only one persistence unit, it is injected using a `@PersistenceContext` without a unit name. Furthermore, the objects having such fields are not EJBs, they are simple Spring beans...<br>
<br>On the other hand, the application has also a `persistence.xml` with two persistence units.<br>The code of the application has `@PersistenceContext` fields with a proper `unitName`, which is mandatory since there are two of them.<br>
<br>Now, when I start my application, Wildfly (specifically the jpa module) scans the code from the jar and chokes on the `@PersistenceContext` without unitNames of my Spring beans:<br><br> DEBUG [org.jboss.as.jpa.messages] (MSC service thread 1-1) persistence unit search for unitName=null referenced from class=the.spring.Bean (annotation=@javax.persistence.PersistenceContext() on void the.spring.Bean.setEntityManager(javax.persistence.EntityManager))<br>
<br><br>To cope with this, I would like to exclude the jar: In TomEE there is a mean to exclude a jar explicitly from being scanned, but I cannot find a similar functionnality in WildFly.<br>I have tried the following configurations without success:<br>
<br> - `jboss-deployment-structure.xml` which is read but without noticeable effect:<br><br> <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"><br> <deployment><br>
<exclusions><br> <module name="deployment.jee-app.war.spring-app.jar" /><br> <!-- I have also tried the following --><br> <!-- <module name="jee-app.war.spring-app.jar" /> --><br>
<!-- <module name="spring-app.jar" /> --><br> </exclusions><br> </deployment><br> </jboss-deployment-structure> <br><br> - `jboss-scanning.xml` which seems to be ignored<br>
<br> <scanning xmlns="urn:jboss:scanning:1.0"><br> <path name="jee-app.war/WEB-INF/lib"><br> <exclude name="spring-app.jar" /><br> </path><br>
</scanning><br><br><br>Both of these files are in the WEB-INF folder of my war application.<br><br>Of course, I cannot modify the spring-app.jar (would be too easy...)<br><br>Needless to say, I have spend a considerable amount of time in the WildFly doc and on Google without finding anything else than exluding subsystems, or overriding locally modules of WildFly...<br>
<br>Thanks for your help!<br><br>Juan Manuel<br><br></div><div>PS: This question is also posted on StackOverflow: <a href="http://stackoverflow.com/q/22932015/3509723">http://stackoverflow.com/q/22932015/3509723</a><br><br>
</div></div></div>