As far as I know Tuscany never handled the case where multiple copies of a
module were available on the CLASSPATH.

Tuscany uses 
classLoader.getResources("META-INF/services/org.apache.tuscany.sca.core.ModuleActivator)
to read the list of module activators. If the same resource is available
from two different jars in the classpath, they are returned as two
resources. This is not a problem for module activators of implementation
types since eventually one gets chosen. But the DataBindingModuleActivator
adds new wire processors to a list, and if multiple versions of these are
available, all of them get added.

The patch attached to TUSCANY-1941 adds only one module activator for each
classname (the classname of the module activator implementation). Only
loadModules is fixed by this patch. Other resources read from
META-INF/services continue to return all resources found on the classpath.

The common code which reads the resources from META-INF/services returns all
the resources from the classpath, except in a multi-classloader environment
where a resource available from multiple classloaders is only returned once.
I am not sure if this code needs to handle the case where the same set of
classes are available from two different sources within a single classloader
(ie, if code other than module activators rely on being processed only
once). I haven't modified this code since there are entries like

org.apache.tuscany.sca.databinding.axiom.OMElement2Externalizable;source=
org.apache.axiom.om.OMElement,target=org.osoa.sca.CallableReference
,weight=10
org.apache.tuscany.sca.databinding.axiom.OMElement2Externalizable;source=
org.apache.axiom.om.OMElement,target=java.io.Externalizable,weight=10


where the same class is used twice, but other parameters are different. I am
not sure if loading of files from META-INF/services should return only one
copy of each of these where all attributes are used for the comparison. I
haven't looked at all the files under META-INF/services, and didn't want to
break anything at this stage. So the patch provides the minimal change
to fix the failure reported here.


On 12/19/07, Andrej Koelewijn <[EMAIL PROTECTED]> wrote:

> Done: https://issues.apache.org/jira/browse/TUSCANY-1941
> Regards,
> Andrej
>
> On Dec 19, 2007 12:19 PM, Simon Laws <[EMAIL PROTECTED]> wrote:
>
> > On Dec 19, 2007 11:00 AM, Andrej Koelewijn <[EMAIL PROTECTED]> wrote:
> >
> > > Hi Simon,
> > > I included everything, including the manifest jar. Removing it doesn't
> > > help.
> > > Removing all the jars from the modules directory does: it works as
> > > expected
> > > when i put only the jars from the libs directory (excluding the
> manifest
> > > jar) on the classpath.
> > > Regards,
> > > Andrej
> > >
> > > On Dec 19, 2007 11:54 AM, Simon Laws <[EMAIL PROTECTED]>
> wrote:
> > >
> > > > On Dec 19, 2007 9:58 AM, Andrej Koelewijn <[EMAIL PROTECTED]>
> > wrote:
> > > >
> > > > > Fixed it. It was a classpath issue, although i'm yet sure what. I
> > had
> > > > put
> > > > > all jar from the libs and modules directories on my classpath.
> After
> > i
> > > > > changed it to only include lib\tuscany-sca-manifest.jar it works
> as
> > > > > expected.
> > > > > Regards,
> > > > > Andrej
> > > > >
> > > >  Hi Andrej
> > > >
> > > > Thanks for coming back with the fix you found. In the case where it
> > > didn't
> > > > work for you were you including all jars from lib include modules
> > > > including
> > > > the manifest jar or just all jars from lib and module without the
> > > manifest
> > > > jar. If you find out anything more let us know.
> > > >
> > > > Regards
> > > >
> > > > Simon
> > > >
> > >
> > Hmm, seems strange. People might want to include tuscany JARs explicitly
> > (as
> > you did) rather than using the manifest jar or the all jar so this
> should
> > work. When you put all the jars from the lib dir on the classpath you
> are
> > also picking up the tuscany-all jar which has all of the classes from
> the
> > jars in /modules. I wonder if there is some difference between that and
> > the
> > modules jars. I'll give this a try when I build the 1.1 RC. Can you
> raise
> > a
> > JIRA to remind me.
> >
> > Thanks
> >
> > Simon
> >
>



-- 
Thank you...

Regards,

Rajini

Reply via email to