cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fagerstrom <>
Subject Re: [osgi] Component management
Date Tue, 05 Jul 2005 16:58:00 GMT
Niclas Hedhman wrote:

>On Tuesday 05 July 2005 23:15, Daniel Fagerstrom wrote:
><snip />
>I have nothing much to add to all your comments, other than I agree with every 
>bit you mention.
>>That is a limiting factor ;), anyway its great to beeing able discuss
>>OSGi and component management with someone who allready has experience
>>in the field.
>I don't feel I have any experience. I am probablty pretty much at the same 
>stage as you, Daniel. Reading the spec up and down, 4 times a day, trying to 
>work out how some small detail is supposed to work.
>Right now I am struggling with getting my "artifact:" protocol to work 
>together with classloaders inside the OSGi platform.
>I can do;
>  URL url = new URL( "artifact:jar:log4j/log4j#1.2.8" );
>  InputStream in = url.openStream();
>  ....; ...
>with out problems, but if I do
>  URL url = new URL( "artifact:jar:log4j/log4j#1.2.8" );
>  URL[] urls = new URL[] { url };
>  ClassLoader parent = getClass().getClassLoader();
>  URLClassLoader ucl = new URLClassLoader( urls, parent );
>  Class cls = ucl.loadClass( "org.apache.log4j.Logger" );
>I will get a ClassNotFoundException. (Same goes for any getResourceAsStream() 
>All of the above in Knopflerfish.
>I am starting to think that the Classloading mechanism doesn't not go through 
>the registered URLStreamHandlerFactory that OSGi put in place.
>In any event, this detail have already taken 2 days and a lo of frustration 
Its not fun all the time, I have also spent some days at similar issues. 
For your problem above, have you tried to set the context classloader as 
described in: (a 
page down or so), it solved my problems in a case similar to yours.

Also if you try to use the bundle: protocol between bundles, you need to 
set the property
which is described in, but 
not in an example in that 
doesn't work until you have set the above property.

helps a lot when you try to understand what the classloader do, and more 
importantly not do ;)


View raw message