You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Leen Toelen <to...@gmail.com> on 2009/09/18 16:03:35 UTC

Dozer

Hi,
I am trying to use Dozer mapping inside felix. My mapping xml files run
without a problem in my unit tests, but when run inside OSGI I get
a ClassNotFoundException.

2009/09/18 13:53:19 | INFO   | jvm 1    | Caused by:
java.lang.ClassNotFoundException:
com.meucci.tpaprocessors.sybase.result.SybaseSmsSendTestPartyResult
...
2009/09/18 13:53:19 | INFO   | jvm 1    |       at
java.lang.ClassLoader.loadClass(ClassLoader.java:252)
2009/09/18 13:53:19 | INFO   | jvm 1    |       at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
2009/09/18 13:53:19 | INFO   | jvm 1    |       at
java.lang.Class.forName0(Native Method)
2009/09/18 13:53:19 | INFO   | jvm 1    |       at
java.lang.Class.forName(Class.java:247)
2009/09/18 13:53:19 | INFO   | jvm 1    |       at org.apache.commons.lang.*
ClassUtils.getClass*(ClassUtils.java:629)
2009/09/18 13:53:19 | INFO   | jvm 1    |       at
org.apache.commons.lang.ClassUtils.getClass(ClassUtils.java:677)
2009/09/18 13:53:19 | INFO   | jvm 1    |       at
org.apache.commons.lang.ClassUtils.getClass(ClassUtils.java:660)
2009/09/18 13:53:19 | INFO   | jvm 1    |       at org.dozer.util.*
MappingUtils.loadClass*(MappingUtils.java:229)

Does anyone know how to solve this problem in felix?

Regards,
Leen

Re: Dozer

Posted by Rob Walker <ro...@ascert.com>.
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: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Dozer

Posted by Leen Toelen <to...@gmail.com>.
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

On Fri, Sep 18, 2009 at 5:43 PM, Richard S. Hall <he...@ungoverned.org>wrote:

> The information given is not enough to know what is going on. What is
> packaged inside of which bundles? Who imports, exports, etc?
>
> -> richard
>
>
> On 9/18/09 16:03, Leen Toelen wrote:
>
>> Hi,
>> I am trying to use Dozer mapping inside felix. My mapping xml files run
>> without a problem in my unit tests, but when run inside OSGI I get
>> a ClassNotFoundException.
>>
>> 2009/09/18 13:53:19 | INFO   | jvm 1    | Caused by:
>> java.lang.ClassNotFoundException:
>> com.meucci.tpaprocessors.sybase.result.SybaseSmsSendTestPartyResult
>> ...
>> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at
>> java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at
>> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at
>> java.lang.Class.forName0(Native Method)
>> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at
>> java.lang.Class.forName(Class.java:247)
>> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at
>> org.apache.commons.lang.*
>> ClassUtils.getClass*(ClassUtils.java:629)
>> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at
>> org.apache.commons.lang.ClassUtils.getClass(ClassUtils.java:677)
>> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at
>> org.apache.commons.lang.ClassUtils.getClass(ClassUtils.java:660)
>> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at org.dozer.util.*
>> MappingUtils.loadClass*(MappingUtils.java:229)
>>
>> Does anyone know how to solve this problem in felix?
>>
>> Regards,
>> Leen
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Dozer

Posted by "Richard S. Hall" <he...@ungoverned.org>.
The information given is not enough to know what is going on. What is 
packaged inside of which bundles? Who imports, exports, etc?

-> richard

On 9/18/09 16:03, Leen Toelen wrote:
> Hi,
> I am trying to use Dozer mapping inside felix. My mapping xml files run
> without a problem in my unit tests, but when run inside OSGI I get
> a ClassNotFoundException.
>
> 2009/09/18 13:53:19 | INFO   | jvm 1    | Caused by:
> java.lang.ClassNotFoundException:
> com.meucci.tpaprocessors.sybase.result.SybaseSmsSendTestPartyResult
> ...
> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at
> java.lang.ClassLoader.loadClass(ClassLoader.java:252)
> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at
> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at
> java.lang.Class.forName0(Native Method)
> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at
> java.lang.Class.forName(Class.java:247)
> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at org.apache.commons.lang.*
> ClassUtils.getClass*(ClassUtils.java:629)
> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at
> org.apache.commons.lang.ClassUtils.getClass(ClassUtils.java:677)
> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at
> org.apache.commons.lang.ClassUtils.getClass(ClassUtils.java:660)
> 2009/09/18 13:53:19 | INFO   | jvm 1    |       at org.dozer.util.*
> MappingUtils.loadClass*(MappingUtils.java:229)
>
> Does anyone know how to solve this problem in felix?
>
> Regards,
> Leen
>
>    

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org