Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsClassloader problem due to Teneo caching mechanism.
https://www.eclipse.org/forums/index.php/mv/msg/136791/431679/#msg_431679
I am facing classloader problem due to Teneo caching mechanism used in
FieldUtil.java. Teneo is returning already cached objects.
Scenario:
Suppose there is a process layer (say PG1) and two service layers (say S1
& S2), PG1 contains two different methods to load Person domain object
from service S1 and S2 respectively. Suppose both of these services have
the same method (say loadPersonData ()) to load the Person object i.e. I
can load the Person object using S1 as well as S2.
As each service layer and process layer will be packed in separate EAR,
which means they will have their own Class Loader.
We have two Junit test cases and both are trying to load the same Person
(say id=100) by using different services i.e. testcase1 is using the
PG1S1 to load Person while the testcase2 is using PG1S2 to
load the same Person object. In this case, the test case which is executed
first pass the test case successfully, however the other test case fails
to load Person.
Now why one of the test cases is failing is:
1. Teneo is internally caches fields (java.lang.reflect.Field) of a domain
object in FieldUtil.java. Since the same field was loaded and cached by
service S1 in the first testcase, so whenever other test case tries to
load the same object, Teneo return the cached object. Below is the
original and modified snippet from FieldUtil.java:
Original Code:
public static Field getField(Class<?> clazz, String fieldName) {
Field field = (Field) fieldMethodCache.get(clazz.getName() + "." +
fieldName);
if (field != null) {
return field;
}
}
I have commented out the caching mechanism from FieldUtils.java which will
solve this problem.
Modified code:
public static Field getField(Class<?> clazz, String fieldName) {
//Field field = (Field) fieldMethodCache.get(clazz.getName() +
"." + fieldName);
Field field = null;
if (field != null) {
return field;
}
}
BRegards,
Ajay Chauhan]]>Ajay 2009-07-21T14:12:55-00:00Re: Classloader problem due to Teneo caching mechanism.
https://www.eclipse.org/forums/index.php/mv/msg/136791/431687/#msg_431687
I see why it fails but I am not yet sure yet... How is teneo used here, it appears to be shared by different layers
(otherwise you would not get hit by this, right?). So it may also be a classloading issue in Teneo which should be
solved there.
gr. Martin
Ajay Chauhan wrote:
> Hello Martin,
>
> I am facing classloader problem due to Teneo caching mechanism used in
> FieldUtil.java. Teneo is returning already cached objects.
> Scenario:
> Suppose there is a process layer (say PG1) and two service layers (say
> S1 & S2), PG1 contains two different methods to load Person domain
> object from service S1 and S2 respectively. Suppose both of these
> services have the same method (say loadPersonData ()) to load the Person
> object i.e. I can load the Person object using S1 as well as S2. As each
> service layer and process layer will be packed in separate EAR, which
> means they will have their own Class Loader. We have two Junit test
> cases and both are trying to load the same Person (say id=100) by using
> different services i.e. testcase1 is using the PG1S1 to load
> Person while the testcase2 is using PG1S2 to load the same
> Person object. In this case, the test case which is executed first pass
> the test case successfully, however the other test case fails to load
> Person.
>
> Now why one of the test cases is failing is:
> 1. Teneo is internally caches fields (java.lang.reflect.Field) of a
> domain object in FieldUtil.java. Since the same field was loaded and
> cached by service S1 in the first testcase, so whenever other test case
> tries to load the same object, Teneo return the cached object. Below is
> the original and modified snippet from FieldUtil.java:
>
> Original Code:
>
> public static Field getField(Class<?> clazz, String fieldName) {
> Field field = (Field) fieldMethodCache.get(clazz.getName() + "." +
> fieldName);
> if (field != null) {
> return field;
> }
> �
> �
> �
> }
>
> I have commented out the caching mechanism from FieldUtils.java which
> will solve this problem.
>
> Modified code:
>
> public static Field getField(Class<?> clazz, String fieldName) {
> //Field field = (Field) fieldMethodCache.get(clazz.getName()
> + "." + fieldName);
> Field field = null;
> if (field != null) {
> return field;
> }
> �
> �
> �
> }
>
> BRegards,
> Ajay Chauhan
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org]]>Martin Taal2009-07-21T15:10:29-00:00Re: Classloader problem due to Teneo caching mechanism.
https://www.eclipse.org/forums/index.php/mv/msg/136791/431724/#msg_431724
Yes, you are right. I am sharing the same Teneo library in two different
EAR files.
Thanks and Regards,
Ajay Chauhan]]>Ajay 2009-07-23T07:42:16-00:00