Announcement Announcement Module
Collapse
No announcement yet.
com.springsource.kernel.osgi.framework.ExtendedCla ssNotFoundException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • com.springsource.kernel.osgi.framework.ExtendedCla ssNotFoundException

    Hi,

    I get 'class not found' exception while have the following bundles structure and run on DM Server 2.0.0 RELEASE:

    Bundle A exposes OSGI service and imports Bundle B

    Bundle B tries to load class of Bundle A and get class not found exception:

    Code:
    com.springsource.kernel.osgi.framework.ExtendedClassNotFoundException: com.ServiceProvider in KernelBundleClassLoader: [bundle=B]
    Class com.ServiceProvider resides in bundle A
    Exception is thrown from Bundle B

    My question is why this happens ? All bundles loaded and started successfully. Does each bundle loaded by different class loaders ?

    Thanks,
    Pavel
    Last edited by pavel.orehov; Apr 26th, 2010, 02:25 PM.

  • #2
    I found what caused to that issue, some import was missing in bundle B to package in bundle A.

    Now I have a new class not found exception for java class:

    Code:
    Caused by: java.lang.ClassNotFoundException: javax.net.SocketFactory 
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494) 
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410) 
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398) 
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105) 
    at com.springsource.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:145)
    What might be the reason that java native class not found ?

    Thanks,
    Pavel

    Comment


    • #3
      Hi Pavel,

      You are right that each bundle is loaded by it's own classloader, the usual class loading structure is not used in OSGi. Any class you want to use (with a very small set of exceptions) must be made avaliable with either an import-package or an import-bundle.

      The first thing I would check is that your bundle is importing the 'javax.net' package. You don't need to worry about exporting it from anywhere as it is avaliable from the system bundle (bundle 0).

      Chris.

      Comment


      • #4
        Chris,

        You are right, the import for javax.net package was missing, I added it and now it works !!!

        I though that java native classes are automatically imported, at least expected for such behavior but now I know this is not the case.

        Thank you for clearing that point.

        Comment


        • #5
          Excellent.

          If you look in the lib directory you will find a java profile file. This lists the packages that are either boot delegated (just avaliable) or system packages (can be imported from the system bundle). Hope this helps in the future.

          Chris.

          Comment

          Working...
          X