users@glassfish.java.net

Re: Glassfish V3, EclipseLink and _at_OneToOne(fetch = FetchType.LAZY) problem

From: Mitesh Meswani <Mitesh.Meswani_at_Sun.COM>
Date: Fri, 05 Mar 2010 16:19:39 -0800

On 3/3/2010 11:33 PM, glassfish_at_javadesktop.org wrote:
> Hi Mitesh,
>
> To try and make a simple example is a bit difficult, since this is a large application that previously used to run fine on Glassfish V2 with TopLink. I have ported the application to Glassfish V3 (not simply just running the unmodified app), but by using all the good new stuff in EJB 3.1. My entity classes, however, have remained the same (because the database is the same). The general packaging of the application has remained the same. Restarting, redeploying, and any combination of such, yields the same results.
>
> The entity classes are packaged in one EJB module, while the persistence.xml file is packaged with the data access beans in another EJB module. The persistence.xml file references the EJB where the data entities are found. I don't know if this could possibly a clue to the problem. Here is the contents of the persistence.xml file :-
>
> <persistence-unit name="Test" transaction-type="JTA">
> <jta-data-source>jdbc/__Test</jta-data-source>
> <jar-file>TestDataEntities.jar</jar-file>
> <properties/>
> </persistence-unit>
>
I think this may be the root cause of the issue. V2 loaded content of
the whole .ear using single class loader where as V3 loads each
components jar in its separate class loader. It is a better practice to
have shared components placed in lib of an ear. Please try deploying
with either of following structure
.ear
    ejb1.jar - Data access bean + META-INF/persistence.xml
    ejb2.jar - Unlike your current packaging, this should not contain
any entities
    lib/entities.jar - The entities are put in here so that they are
loaded by an ear level class loader

.ear
   ejb1.jar - Data access bean
   ejb2.jar - Unlike your current packaging, this should not contain any
entities
   lib/pu.jar - The self contained persistence unit contains entities +
META-INF/persitence.xml