Leen
Unfortunately - libraries that use getContextClassLoader() for dynamic
classloading is a long standing nasty within a structured classloading
environment such as OSGi. The problem is the library is using a Thread
local attribute to determine for itself what classloader to use, which
defeats the handling OSGi would have done for it.
Your workaround is the one most of us use to get around this.
-- Rob
Leen Toelen wrote:
Hi,
there are three bundles where bundle A and B define and export package.
Bundle C contains the dozer mapping file and maps a class from A to a class
from B. Budle C throws a ClassNotFoundException.
I was able to work around the problem by setting
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
package C;
public B transform(
A a) throws Exception {
//workaround
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
List<String> myMappingFiles = new ArrayList<String>();
myMappingFiles.add(MAPPING_FILE);
DozerBeanMapper mapper = new DozerBeanMapper(myMappingFiles);
B b = new B();
mapper.map(a, b);//throws Exception
return b;
}
Regards,
Lee
__________ Information from ESET Smart Security, version of virus signature
database 4441 (20090919) __________
The message was checked by ESET Smart Security.
http://www.eset.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]