Ok now I see.
Thanks for your quick response !

/Pierre


Karl Pauls wrote:
Well, we do some magic in certain cases where we can detect that there
is a classload instigated by a class originating from outside of Felix
that targets a class available from the outside. This is necessary
because certain libraries as e.g., swing make some faulty assumptions
about what classloader they can use to get to their classes.
Otherwise, one would have to bootdelegate (or do the dynamic-import
thing) for packages that should not matter to the bundle.

I think that is what is happening in your case. The classload should
not be done using the classloader of your bundle but the jdk is using
it anyways -- hence, we detect that situation and bootdelegate for you
:-)

regards,

Karl

On Mon, Jun 2, 2008 at 7:28 AM, Pierre De Rop
<[EMAIL PROTECTED]> wrote:
Hello every one;

We are using Knopflerfish on top of our application server, and we would
like to jump to Felix.
But I have noticed that KF and Felix don't look like to behave similarly
when using libraries and
thread context class loader.

Because I don't want to bother you with the whole story of our context, I
have made a sample code
which illustrates the problem (if any, though).

Here it is: in the following bundle activator, I set the thread context
class loader, just before
instantiating a SAX xml reader:

  package test;
    import static java.lang.System.out;
  import org.osgi.framework.*;
  import org.xml.sax.*;
  import org.xml.sax.helpers.*;

  public class Activator implements BundleActivator {
    public void start(BundleContext context) throws Exception {
      try {
        // Set the Thread CCL to my bundle class loader

Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
          // The following createXMLReader method will actually use the TCCL
for loading the class
        // "com.sun.org.apache.xerces.internal.parsers.SAXParser" which is
located in the jdk.
        XMLReader reader =
org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
        out.println(reader);
      } catch (Throwable t) {
        t.printStackTrace();
      }
    }
    ...

Here is my corresponding manifest's Import-Package header:

  Import-Package: org.osgi.framework,
   org.xml.sax,
   org.xml.sax.helpers

Please notice that I don't use the org.osgi.framework.bootdelegation
parameter neither with KF, nor
with Felix.

KnopflerFish (2.0.5) behavior:
---------------------------------------

 When the createXMLReader() method is invoked, it tries to load the
 "com.sun.org.apache.xerces.internal.parsers.SAXParser" using the Thread CCL
(which points to my
 bundle CL) and gets an annoying ClassNotFoundException.

 * My understanding is: createXMLReader() gets this exception because I
don't have imported the
   failed package from my manifest.
 * So I work around by adding a "DynamicImport-Package: *" in my manifest
and it works fine.

Felix (1.0.4) behavior:
----------------------------

 Now, with Felix, all works just fine by default ! (without having to
provide
 "DynamicImport-Package: *" in my manifest).

-> So far so good, but could any one please explain how Felix is able to
load the
 com.sun.org.apache.xerces.internal.parsers package, even if I don't have
imported it from my
 manifest ?
 (I have checked the code in the createXMLReader() jdk method, and it does
not fall back to the jdk
 bootstrap class loader if the TCCL don't find the class
com.sun.org.apache.xerces.internal.parsers.SAXParser ...)

Kind Regards
/Pierre


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






Reply via email to