Hello²

And you're problem is described at this issue:
https://issues.apache.org/jira/browse/CAMEL-10513. Camel 2.19.0 changed the
initialization time in blueprint - so that's why you have different
thread/TCCL.

regards
Grzegorz Grzybek

2017-07-14 19:24 GMT+02:00 Grzegorz Grzybek <gr.grzy...@gmail.com>:

> Hello
>
> Yes. Never, ever use thread context class loader - in blueprint you can't
> be sure what thread you're using. And you don't want to cause memory leaks.
>
> if you have bundle reference or bundlecontext, you can get any bundle and
> use it to load resource.
>
> regards
> Grzegorz Grzybek
>
> 2017-07-14 17:45 GMT+02:00 Claus Ibsen <claus.ib...@gmail.com>:
>
>> In pure OSGi that is not the way to load resources from the classpath.
>> OSGi has its own set of APIs for that.
>>
>> You should load via BundleContext and Bundle
>> https://osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleContext.html
>> https://osgi.org/javadoc/r4v43/core/org/osgi/framework/Bundle.html
>>
>> That is also what Camel uses when its runs in OSGi and its
>> ClassResolver via the OsgiClassResolver class.
>>
>> It may be that the current thread in the past may have worked, but
>> there is no guarantee. And what have changed is hard to tell as Karaf
>> and Camel upgrades are using newer version of OSGi and Blueprint etc.
>>
>> On Fri, Jul 14, 2017 at 5:39 PM, rsteppac2 <r...@steppacher.name> wrote:
>> > Hello Claus,
>> >
>> > thanks for your suggestions!
>> >
>> > it is 3rd party library code, so I cannot just change it. What I could
>> do, I
>> > guess, is to wrap the library's factory code in my own and set the
>> context
>> > classloader of the current thread to the application context class
>> loader
>> > before delegating to the actual factory.
>> >
>> > What I do not quite understand is why the code works consistently with
>> Camel
>> > versions < 2.19.0 and consistently not with >= 2.19.0.
>> > And why would the classloader of the thread that builds the blueprint
>> > context based on the XML in my bundle not have access to a resource
>> that is
>> > at the root of that very same bundle?
>> >
>> >
>> > Thanks again.
>> > Ralf
>> >
>> >
>> >
>> > --
>> > View this message in context: http://camel.465427.n5.nabble.
>> com/getResourceAsStream-in-OSGi-bundle-not-working-with-Came
>> l-2-19-tp5807017p5807021.html
>> > Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> http://davsclaus.com @davsclaus
>> Camel in Action 2: https://www.manning.com/ibsen2
>>
>
>

Reply via email to