camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Classloading and OSGI
Date Tue, 03 Mar 2009 14:35:33 GMT
ObjectHelper will load the class with trying to use the
threadContextClassLoader first.

Since your bundle doen't import the org.apache.camel.component.jms.*.
The threadContextClassLoader which is set to use your bundle classloader
can't see the QueueBrowserStrategy. You will get the ClassNotFoundException.

I did a little trick to let the ObjectHelper to load class with the
JmsComponent's classloader. Hope it can work in your case, if you don't
want to change you bundle's META-INF\MANIFEST.MF import package.

-        Class<?> type =
ObjectHelper.loadClass(DEFAULT_QUEUE_BROWSE_STRATEGY);
+        Class<?> type =
ObjectHelper.loadClass(DEFAULT_QUEUE_BROWSE_STRATEGY,
JmsComponent.class.getClassLoader());


Willem


atlep wrote:
> No they don't..
> 
> I peeked into the code that tries to load the QueueBrowserStrategy, and it
> seemt that it doesnt try the contextclasslaoder at all (I am using camel
> 1.5.0), did i peek hard enough?
> 
> Ideally one don't want to have references to packages other than camel-core,
> and let camel sort the refrences out. In osgi cases when the classloader is
> important one could have some explicit classloader configuration in
> camelContext..
> 
> I will try to check the 2.0 fix, thank you for your help! :)
> 
> willem.jiang wrote:
>> I just want to ask a question, did your bundle has the import of
>> org.apache.camel.component.jms.* ?
>>
>> If so, the ObjectHelper should be able to load the default
>> QueueBrowserStrategy.
>>
>> Willem
>>
>>
>> willem.jiang wrote:
>>> Hi ,  
>>>
>>> I just created a JIRA[1] for your issue.
>>> And will commit a quick fix for it.
>>> If you have time please check out the latest camel 2.0 snapshot to verify
>>> it.
>>>
>>> [1] https://issues.apache.org/activemq/browse/CAMEL-1412
>>>
>>> Willem
>>>
>>>
>>> atlep wrote:
>>>> I am using camel in  a OSGI (Felix) environment, and I regularly bump
>>>> into classloading issues:
>>>>
>>>> THe most recentones are
>>>> The JSM Component cant find the QueueBrowserStrategy because it cannot
>>>> see the spring bundle that exports it, because it is using a "wrong "
>>>> classloader to try to load it (it uses o.a.c.util.ObjectHelper's
>>>> classloader).
>>>>
>>>> The activemq component cannot load object messages because it cannot
>>>> deserialize the body. I have tried setting the thread contextclassloader
>>>> to my bundles classloader, but it seems it does not use the context
>>>> classloader.
>>>>
>>>> Are there any good practices or patterns regarding using camel +
>>>> activemq in a OSGi environment, without resorting to servicemix? 
>>>>
>>>> Maybe these wrinkles are ironed out in camel 2.0?
>>>>
>>>
>>
> 


Mime
View raw message