You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Dain Sundstrom <da...@iq80.com> on 2006/12/28 02:34:52 UTC

JPQLExpressionBuilder uses wrong classloader

I've been working on a getting JPA runtime enhancement and have run  
into a problem where OpenJPA is loading my classes from the wrong  
class loader.  When I create a persistence unit info it supplies a  
specific class loader for OpenJPA to use when resolving application  
classes.  When I execute a query the JPQLExpressionBuilder simply  
uses getClass().getClassLoader() to load classes.  In my case this is  
the system class loader which contains unenhanced classes and not the  
class loader for the persistence unit which has properly enhanced  
classes.

It is my understand that OpenJPA should use the class loader obtained  
from the PersistenceUnitInfo for all class loading.  Is this correct?

If that is correct, is this a bug in OpenJPA?

-dain


Re: JPQLExpressionBuilder uses wrong classloader

Posted by Marc Prud'hommeaux <mp...@apache.org>.
Dain-

I assume you are specifying the ClassLoader by using your own  
subclass of PersistenceUnitInfoImpl. OpenJPA should be using your  
ClassLoader, although if the same class name is available in both  
your classloader as well as the system classloader, then I think the  
results are undefined.

Is it possible to check to see if your ClassLoader is used if the  
class to be loaded is *not* available in the system classloader?



On Dec 27, 2006, at 8:38 PM, Dain Sundstrom wrote:

> Also it appears that the Broker be loading classes from the thread  
> context class loader when persist is called.
>
> -dain
>
> On Dec 27, 2006, at 5:34 PM, Dain Sundstrom wrote:
>
>> I've been working on a getting JPA runtime enhancement and have  
>> run into a problem where OpenJPA is loading my classes from the  
>> wrong class loader.  When I create a persistence unit info it  
>> supplies a specific class loader for OpenJPA to use when resolving  
>> application classes.  When I execute a query the  
>> JPQLExpressionBuilder simply uses getClass().getClassLoader() to  
>> load classes.  In my case this is the system class loader which  
>> contains unenhanced classes and not the class loader for the  
>> persistence unit which has properly enhanced classes.
>>
>> It is my understand that OpenJPA should use the class loader  
>> obtained from the PersistenceUnitInfo for all class loading.  Is  
>> this correct?
>>
>> If that is correct, is this a bug in OpenJPA?
>>
>> -dain
>


Re: JPQLExpressionBuilder uses wrong classloader

Posted by Dain Sundstrom <da...@iq80.com>.
Also it appears that the Broker be loading classes from the thread  
context class loader when persist is called.

-dain

On Dec 27, 2006, at 5:34 PM, Dain Sundstrom wrote:

> I've been working on a getting JPA runtime enhancement and have run  
> into a problem where OpenJPA is loading my classes from the wrong  
> class loader.  When I create a persistence unit info it supplies a  
> specific class loader for OpenJPA to use when resolving application  
> classes.  When I execute a query the JPQLExpressionBuilder simply  
> uses getClass().getClassLoader() to load classes.  In my case this  
> is the system class loader which contains unenhanced classes and  
> not the class loader for the persistence unit which has properly  
> enhanced classes.
>
> It is my understand that OpenJPA should use the class loader  
> obtained from the PersistenceUnitInfo for all class loading.  Is  
> this correct?
>
> If that is correct, is this a bug in OpenJPA?
>
> -dain