John,
Yes, you have struck on an issue here, which is kind of ugly.
For the most part, this issue revolves around that fact that many of the
libraries in the JRE make the assumption that they can get to the system
class loader from any class loader they choose. For OSGi bundle class
loaders, this is not true, since we don't delegate to the parent by default.
I have, however, implemented a hack in Felix that tries to check for
some of these situations and properly delegate to the parent class
loader, but it still doesn't not detect every situation...I just
discovered one such situation two days ago with Swing.
You are correct that the boot delegation property will help us out here,
because we can at least put problematic Sun implementation packages on
it. I will try to find the time to implement this property in the next
couple days...it should be pretty straight forward. I will post to the
list and we will set the default value in config.properties to include
these packages to you can remove them from your bundles.
I would also be interested in seeing small bundles that demonstrate the
problem, so that I might be able to see if there are ways to improve my
hack to detect this situation automatically.
Sorry for the pain...unfortunately, it is hard to be modular in a
non-modular world. ;-)
-> richard
John E. Conlon wrote:
Hello Richard,
As you mentioned after the change I had to edit my bundle Import-Package
headers to get bundles to resolve without NoClassDefFoundErrors.
Now the tough part about this was that I had to not only import all the
javax classes I was using but also the sun, and even the com.sun
packages in the imports as well. Then I had to add the various
javax.xxx, sun.xxx and com.sun.xxx packages to the config.properties
file's org.osgi.framework.system.packages property as well.
Now I must confess that reading the classloading part of the OSGi spec
makes my eyes glaze over, but I did notice section 3.8.3 discussion of
parent delegation. It talks about a bootdelegation property that can add
packages to the parent classloader like this:
property org.osgi.framework.bootdelegation=sun.*,com.sun.*
Maybe I am paranoid but I feel uncomfortable doing anything (even
declaring imports in bundles) with the sun and com.sun packages. Could
the bootdelegation property eventually come to the rescue?
cheers,
John
On Wed, 2006-04-05 at 04:54 -0400, Richard S. Hall wrote:
Hello everyone,
I just wanted to let you know that I discovered and fixed a bug in Felix
class loading that was accidentally exposing classes on the class path
to bundles, even if they did not import them.
This bug was introduced during the module layer refactoring.
I am posting a message about this to let people know that they should
"svn update" and after they do, they might experience
NoClassDefFoundErrors and the like if their bundles' manifests are
incomplete. If you run into this situation, most likely, you just need
to add the package to the Import-Package header of the bundle.
-> richard