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.
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...
On the other hand, the application has also a
`persistence.xml` with two persistence units.
The code of the application has `@PersistenceContext` fields
with a proper `unitName`, which is mandatory since there are
two of them.
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:
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))
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.
I have tried the following configurations without success:
- `jboss-deployment-structure.xml` which is read but
without noticeable effect:
<jboss-deployment-structure
xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<module
name="deployment.jee-app.war.spring-app.jar" />
<!-- I have also tried the following -->
<!-- <module
name="jee-app.war.spring-app.jar" /> -->
<!-- <module name="spring-app.jar" />
-->
</exclusions>
</deployment>
</jboss-deployment-structure>
- `jboss-scanning.xml` which seems to be ignored
<scanning xmlns="urn:jboss:scanning:1.0">
<path name="jee-app.war/WEB-INF/lib">
<exclude name="spring-app.jar" />
</path>
</scanning>
Both of these files are in the WEB-INF folder of my war
application.
Of course, I cannot modify the spring-app.jar (would be too
easy...)
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...
Thanks for your help!
Juan Manuel