Would defining the persistence unit on EAR level help out?
Well, we already define the persistence units in a separate persistence.xml, i.e.
-- persistence.xml -> references the entity jar's via <jar-file>
-- daoService -> entity manager ref
The problem is that our jar files represent components that might be reused in different applications.
However, each application might define different persistence units that the components should reside in.
I could set a different persistence unit per component jar but then I'd have many units in persistence.xml.
Additionally, I'm not sure that if each unit references only a subset of the entities, queries like "select A.b from A" would work in cases where A is in PU "A" and B or A.b is registered in PU "B". Plus registering A and B in both units doesn't seem that good (which unit is the owner? are the instances shared? etc.)