You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by ant elder <an...@gmail.com> on 2010/01/15 12:03:17 UTC
ContextClassLoaderServiceDiscoverer use of TCCL
I've hit a problem with ContextClassLoaderServiceDiscoverer when
multiple Nodes are started with different Thread Context ClassLoaders
in that ContextClassLoaderServiceDiscoverer always returns its cached
classloader which is from the TCCL of the first Node that was started.
I've changed this in r899589 so getContextClassLoader just returns the
current TCCL which gets my test passing, but the
ContextClassLoaderServiceDiscoverer is still using the cached one in
other places, is there any reason this couldn't just be using the
current TCCL everywhere?
...ant
Re: ContextClassLoaderServiceDiscoverer use of TCCL
Posted by Raymond Feng <en...@gmail.com>.
There is a bit history here. ContextClassLoaderServiceDiscoverer used to be
ClassLoaderServiceDiscoverer and it expects the Node to configure it with
the runtime classloader. Then we moved into the world that NodeFactory can
be shared by multiple nodes which can have different TCCLs.
We use ServiceDiscovery.getInstance().getContextClassLoader() to set the
parent classloader for the contributions. TCCL is not always reliable here
so we leave it to the ServiceDiscover impl.
I suggest that we make the following changes:
1) Removed the cached classloader
2) For classloader based discovery, we can use
ContextClassLoaderServiceDiscoverer.class.getClassLoader() assuming that all
core and extension modules will be loaded by the same classloader (OSGi has
its discoverer). Using TCCL is fine too if it has access to the Tuscany
runtime classes.
3) Return current TCCL from
org.apache.tuscany.sca.extensibility.ContextClassLoaderServiceDiscoverer.getContextClassLoader().
Thanks,
Raymond
--------------------------------------------------
From: "ant elder" <an...@apache.org>
Sent: Friday, January 15, 2010 3:42 AM
To: <de...@tuscany.apache.org>
Subject: Re: ContextClassLoaderServiceDiscoverer use of TCCL
> On Fri, Jan 15, 2010 at 11:34 AM, Simon Laws <si...@googlemail.com>
> wrote:
>> Firstly, it does seem a little odd that it has to cache it. There is
>> extra effort in doing it so it would be interesting to know why.
>>
>> This is probably a stupid question but in the new world of the
>> NodeFactory I thought we only loaded the extensions once. Presumably
>> using the classloader that loads the factory. What's the effect you
>> see in your scenario when you have multiple nodes on different
>> classloaders?
>>
>> Simon
>>
>
> The scenario is in Tomcat where the Tuscany jars are shared and each
> webapp starts a Node. So the extensions are only started once and the
> first time ContextClassLoaderServiceDiscoverer gets used it caches the
> current value for the TCCL which as its cached is also used for every
> other Node in all the other webapps. So then things like the
> ModelResolvers try find things using an incorrect classloader.
>
> ...ant
Re: ContextClassLoaderServiceDiscoverer use of TCCL
Posted by ant elder <an...@apache.org>.
On Fri, Jan 15, 2010 at 11:34 AM, Simon Laws <si...@googlemail.com> wrote:
> Firstly, it does seem a little odd that it has to cache it. There is
> extra effort in doing it so it would be interesting to know why.
>
> This is probably a stupid question but in the new world of the
> NodeFactory I thought we only loaded the extensions once. Presumably
> using the classloader that loads the factory. What's the effect you
> see in your scenario when you have multiple nodes on different
> classloaders?
>
> Simon
>
The scenario is in Tomcat where the Tuscany jars are shared and each
webapp starts a Node. So the extensions are only started once and the
first time ContextClassLoaderServiceDiscoverer gets used it caches the
current value for the TCCL which as its cached is also used for every
other Node in all the other webapps. So then things like the
ModelResolvers try find things using an incorrect classloader.
...ant
Re: ContextClassLoaderServiceDiscoverer use of TCCL
Posted by Simon Laws <si...@googlemail.com>.
Firstly, it does seem a little odd that it has to cache it. There is
extra effort in doing it so it would be interesting to know why.
This is probably a stupid question but in the new world of the
NodeFactory I thought we only loaded the extensions once. Presumably
using the classloader that loads the factory. What's the effect you
see in your scenario when you have multiple nodes on different
classloaders?
Simon