On 3/23/2011 8:27 AM, Cédric Marcone wrote:
> Thank you : it works !
>
> For the sake of completeness, if someone is interested :
>
> 1) I added the two following lines in my persistence.xml :
>
> <jar-file>../myejb1.jar</jar-file>
> <jar-file>../myejb2.jar</jar-file>
>
> -> Now my entities are auto-discovered.
Though this might "work", it is not the recommended approach for
GlassFish V3. Bytecode weaving will not work with this approach. This is
because the pu in the lib dir is "loaded" by parent class loader of the
respective classloaders that loads myejb1.jar and myejb2.jar. The
bytecode transformers will be installed on the parent classloader and
will never be triggered while loading classes from myejb1.jar and
myejb2.jar. If you want to have entities in two different jars, put the
jars also in lib dir.
Thanks,
Mitesh
> 2) The jar file containing the persistence.xml doesn't need to embed an entity.
>
> Thanks again, you made my day !
> --
> Cédric
>
> Le 22 mars 2011 à 19:26, Mitesh Meswani a écrit :
>
>> To declare a PU at ear level you need to put it in lib/ dir of the ear like as follows
>>
>> myear
>> myejb1.jar
>> myejb2.jar
>> lib/
>> mypu.jar
>> META-INF/persistence.xml
>> MyEntity.class
>>
>>
>> On 3/22/2011 4:08 AM, Cédric Marcone wrote:
>>> Hello,
>>>
>>> I'm pretty sure there is an easy way to solve my problem but I clearly failed to find a solution alone...
>>>
>>> I'm building an application that has 2 EJB modules.
>>> Both of those modules contain entities.
>>> Those entities needs to persist in the same database.
>>> The target app server is GF 3.1.
>>>
>>> I could clearly declare 2 persistence.xml (one per EJB module) but :
>>>
>>> 1) that's far from ideal
>>> 2) one of those modules is a library that cannot be modified
>>>
>>> I saw that I could package the persistence.xml at the ear level but I cannot get it to work.
>>>
>>> Did anyone ever tried - or succeeded ;) - in doing such a thing ?
>>>
>>> Thanks for your help.
>>> --
>>> Cédric