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.e.
I can do;
URL url = new URL( "artifact:jar:log4j/log4j#1.2.8" );
InputStream in = url.openStream();
.... in.read(); ...
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
:o)
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: http://www.knopflerfish.org/programming.html#activator (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
-Dorg.knopflerfish.osgi.registerbundleurlhandler=true
which is described in http://www.knopflerfish.org/changelog.html, but
not in an example in http://www.knopflerfish.org/programming.html that
doesn't work until you have set the above property.
Setting:
-Dorg.knopflerfish.framework.debug.classloader=true
helps a lot when you try to understand what the classloader do, and more
importantly not do ;)
/Daniel