Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [Teneo] JMX MBean and class loading issues
| | | | |
Re: [Teneo] JMX MBean and class loading issues [message #125435 is a reply to message #125421] |
Sat, 07 June 2008 12:55 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Matthias,
In the basis Teneo uses the classloader set in the ClassLoaderResolver class. You can see the
setClassLoaderStrategy method there which you can use to set a ClassLoaderStrategy. There are
currently two strategies available: ClassClassloaderStrategy, ContextClassLoaderStrategy (the default).
You can try to set the ClassClassLoaderStrategy to see if it makes a difference.
Can you check which classloaderstrategy is being used currently? Just set a breakpoint in
ClassLoaderResolver.getClassLoaderStrategy. Then I think the best approach is to research what are
the available classloaders for the class and thread, and see which in the end uses the osgi class
loader (each classloader has a parent classloader).
So it is a bit of trial and error but this should be solvable.
gr. Martin
Matthias wrote:
> Martin Taal wrote:
>
>> Hi Matthias,
>> I can now see that it goes wrong when loading a classloader. To load the Yes,
> classloader Teneo uses the
>> org.eclipse.emf.teneo.classloader.ClassLoaderResolver class. This
>> class has
> a static member
>> (ClassLoaderStrategy) which you can set as the default classloader. As a
> default the
>> ContextClassloader is used (which does
> Thread.currentThread().getContextClassLoader() to find the
>> classloader). Normally this works fine.
>> What I can see is that the last part of the stacktrace does not use
>> the osgi
> classloader but the
>> default sun classloader. This is where the issue(s) are coming from.
>
>> Can you debug into the
> org.eclipse.emf.teneo.classloader.ClassLoaderResolver.classF orName
> method and
>> then check which classloader is used?
>
>> gr. Martin
>
>
>
> Hello Martin!
>
> Yes you are right its definitly a class loader issue.
>
> When accessing my model instances from any other plug-in than the JMX
> MBeans the org.eclipse.core.runtime.internal.adaptor.ContextFinder gets
> returned from the current Thread
> (Thread.currentThread.getContextClassLoader() ). But if I access the
> model or other EMF/Teneo specific objects then the current Thread
> (MBean) returns sun.misc.Launcher$AppClassLoader. And so I think this
> Class loader cannot find the Teneo classes! Must we use the Context
> class loader always?!? Can we access the ContextFinder classloader from
> the code?!
>
> Can we handle this issue with the Teneo classloading implementation or
> is this problem only solvable on the JMX side?!?
>
> Thank you!
>
> Best Reagrds,
> Matthias
>
--
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: [Teneo] JMX MBean and class loading issues [message #125602 is a reply to message #125516] |
Tue, 10 June 2008 13:07 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Matthias,
Good that it works, classloading issues are always very annoying.
Regarding this, afaics no there is no 'bug' in Teneo. I am not sure either if this can be tagged as
'changing the teneo plugin'. It is just setting an option just as also setting the database driver etc.
Maybe the strange thing with the classloader compared to other extensions is that you both have to
set the ClassLoaderStrategy in the ClassLoaderResolver. This can be made simpler I think to always
use the one defined in the ClassLoaderResolver. I will look at that.
My idea was/is that the context class loader (which uses the thread classloader) is a good default.
gr. Martin
Matthias wrote:
> Hello Martin,
>
> Thank you for your help! Finally, it works ;) !!!!
> As you suggested, I have set the ClassLoaderStrategy in the
> ClassLoaderResolver class to "setClassLoaderStrategy(new
> ClassClassLoaderStrategy());" in the static initializer.
>
> Then I have added this code to my data store initialization part:
> "localDataStore.getExtensionManager().registerExtension(
> ClassLoaderStrategy.class.getName(),
> ClassClassLoaderStrategy.class.getName());"
>
> All my other plug-ins are working so far with this changes. But is there
> a "cleaner" way to set the ClassLoaderStrategy without changing the
> org.eclipse.emf.teneo plug-in?!? Why is not the ClassClassLoaderStrategy
> the default one used?!? Is there a "bug" in Teneo?!?
>
> Again, thank you for your help!
>
> Matthias!
>
--
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: [Teneo] JMX MBean and class loading issues [message #619215 is a reply to message #125421] |
Sat, 07 June 2008 12:55 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Matthias,
In the basis Teneo uses the classloader set in the ClassLoaderResolver class. You can see the
setClassLoaderStrategy method there which you can use to set a ClassLoaderStrategy. There are
currently two strategies available: ClassClassloaderStrategy, ContextClassLoaderStrategy (the default).
You can try to set the ClassClassLoaderStrategy to see if it makes a difference.
Can you check which classloaderstrategy is being used currently? Just set a breakpoint in
ClassLoaderResolver.getClassLoaderStrategy. Then I think the best approach is to research what are
the available classloaders for the class and thread, and see which in the end uses the osgi class
loader (each classloader has a parent classloader).
So it is a bit of trial and error but this should be solvable.
gr. Martin
Matthias wrote:
> Martin Taal wrote:
>
>> Hi Matthias,
>> I can now see that it goes wrong when loading a classloader. To load the Yes,
> classloader Teneo uses the
>> org.eclipse.emf.teneo.classloader.ClassLoaderResolver class. This
>> class has
> a static member
>> (ClassLoaderStrategy) which you can set as the default classloader. As a
> default the
>> ContextClassloader is used (which does
> Thread.currentThread().getContextClassLoader() to find the
>> classloader). Normally this works fine.
>> What I can see is that the last part of the stacktrace does not use
>> the osgi
> classloader but the
>> default sun classloader. This is where the issue(s) are coming from.
>
>> Can you debug into the
> org.eclipse.emf.teneo.classloader.ClassLoaderResolver.classF orName
> method and
>> then check which classloader is used?
>
>> gr. Martin
>
>
>
> Hello Martin!
>
> Yes you are right its definitly a class loader issue.
>
> When accessing my model instances from any other plug-in than the JMX
> MBeans the org.eclipse.core.runtime.internal.adaptor.ContextFinder gets
> returned from the current Thread
> (Thread.currentThread.getContextClassLoader() ). But if I access the
> model or other EMF/Teneo specific objects then the current Thread
> (MBean) returns sun.misc.Launcher$AppClassLoader. And so I think this
> Class loader cannot find the Teneo classes! Must we use the Context
> class loader always?!? Can we access the ContextFinder classloader from
> the code?!
>
> Can we handle this issue with the Teneo classloading implementation or
> is this problem only solvable on the JMX side?!?
>
> Thank you!
>
> Best Reagrds,
> Matthias
>
--
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: [Teneo] JMX MBean and class loading issues [message #619227 is a reply to message #125516] |
Tue, 10 June 2008 13:07 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Matthias,
Good that it works, classloading issues are always very annoying.
Regarding this, afaics no there is no 'bug' in Teneo. I am not sure either if this can be tagged as
'changing the teneo plugin'. It is just setting an option just as also setting the database driver etc.
Maybe the strange thing with the classloader compared to other extensions is that you both have to
set the ClassLoaderStrategy in the ClassLoaderResolver. This can be made simpler I think to always
use the one defined in the ClassLoaderResolver. I will look at that.
My idea was/is that the context class loader (which uses the thread classloader) is a good default.
gr. Martin
Matthias wrote:
> Hello Martin,
>
> Thank you for your help! Finally, it works ;) !!!!
> As you suggested, I have set the ClassLoaderStrategy in the
> ClassLoaderResolver class to "setClassLoaderStrategy(new
> ClassClassLoaderStrategy());" in the static initializer.
>
> Then I have added this code to my data store initialization part:
> "localDataStore.getExtensionManager().registerExtension(
> ClassLoaderStrategy.class.getName(),
> ClassClassLoaderStrategy.class.getName());"
>
> All my other plug-ins are working so far with this changes. But is there
> a "cleaner" way to set the ClassLoaderStrategy without changing the
> org.eclipse.emf.teneo plug-in?!? Why is not the ClassClassLoaderStrategy
> the default one used?!? Is there a "bug" in Teneo?!?
>
> Again, thank you for your help!
>
> Matthias!
>
--
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
|
|
|
Goto Forum:
Current Time: Fri Apr 26 19:16:05 GMT 2024
Powered by FUDForum. Page generated in 0.04573 seconds
|