Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Classloader problem due to Teneo caching mechanism.
Classloader problem due to Teneo caching mechanism. [message #431679] Tue, 21 July 2009 14:12 Go to next message
Ajay  is currently offline Ajay Friend
Messages: 12
Registered: July 2009
Junior Member
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
Re: Classloader problem due to Teneo caching mechanism. [message #431687 is a reply to message #431679] Tue, 21 July 2009 15:10 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ajay,
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&#61664;S1 to load
> Person while the testcase2 is using PG1&#61664;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
Re: Classloader problem due to Teneo caching mechanism. [message #431724 is a reply to message #431687] Thu, 23 July 2009 07:42 Go to previous message
Ajay  is currently offline Ajay Friend
Messages: 12
Registered: July 2009
Junior Member
Hello Martin,

Yes, you are right. I am sharing the same Teneo library in two different
EAR files.

Thanks and Regards,
Ajay Chauhan
Previous Topic:[Validation] Deterioration of performance with Eclipse Galileo due to Tracing
Next Topic:load ecore file into dynamic EMF
Goto Forum:
  


Current Time: Tue Apr 16 19:37:52 GMT 2024

Powered by FUDForum. Page generated in 0.74947 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top