Q: Is it possible to define a default persistence-context-ref for an EJB jar? I have an EAR project in which I defined


*

*a "persistance" JAR containing only the entities I want to persist (and a persistence.xml)

*an EJB Jar containing the active components


When deploying those components in an EAR (built using maven plugins), I always get 

org.glassfish.deployment.common.DeploymentException: Could not resolve a persistence unit corresponding to the persistence-context-ref-name [base-entities] in the scope of the module called [ear-0.0.1-SNAPSHOT#ejbs-0.0.1-SNAPSHOT.jar]. Please verify your application.

How can I fix that ? I first thought about defining a persistence-context-ref for the whole EJB jar (in ejb-jar.xml), but it doesn't seem to be possible. So, should i write a secondary persistence.xml linking to the first ?

A: As dumb as it seems (afterwards) the simplest solution to that problem is to put in the EJB jar a persistence.xml that copies the initial one. Indeed, from what I understand, the EAR will load persistence elements from the EJB module (and not from the JAR). As a consequence, it is the EJB module that must define the persistence.xml configuration file.
