Hi Jakob,

I guess if you want to call it a "severe" bug, then it's a bug in the
documentation.
I will put a comment in the Javadoc to prevent confusion when mapping
files are used. The problem is that the Mapping handles it's own class
loading, for files which are defined in the mapping, which is why you
can set a class loader for the Mapping object as well. Many people don't
use mapping files, they rely on Castor generated source code or
introspection, so the ClassLoader set with the Unmarshaller will work in
those cases. Also, The unmarshaller will not set the ClassLoader for the
Mapping, it's up to the user to handle that.

The best thing to to do is set the ClassLoader in 3 places:

Marshaller, Unmarshaller, and if a mapping file is being used then the
Mapping.

Thanks,

--Keith




[EMAIL PROTECTED] wrote:
> 
> Try the following for some class c that has been loaded by a non-default
> classloader cl and a Mapping m that has been created using the default
> constructor (i.e. no classloader has been set):
> 
> Unmarshaller unmarshaller = new Unmarshaller(c);
> unmarshaller.setClassLoader(cl);
> unmarshaller.setMapping(m);
> 
> In contrast to what the setClassLoader call suggests, the unmarshaller will not
> be able to handle classes that are visible only for the classloader cl since it
> uses the default classloader. The reason is that Unmarshaller references a
> ClassLoader object and a Mapping object which again references a ClassLoader
> object, and it is the latter classloader that is used. It is silently assumed
> that these ClassLoaders coincide -- which is not guaranteed by the
> implementation and in fact does not hold in my example. Even a setClassLoader
> after setMapping would not force the Unmarshaller to use the correct
> classloader.The workaround is of cause to create the Mapping object with the
> desired classloader, but without poking into the source code this had been hard
> to figure out.
> 
> All the best,
> 
> Jakob Spies
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to