Results 1 to 5 of 5

Thread: com.springsource.kernel.osgi.framework.ExtendedCla ssNotFoundException

  1. #1
    Join Date
    Mar 2010
    Posts
    28

    Default 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 at 01:25 PM.

  2. #2
    Join Date
    Mar 2010
    Posts
    28

    Default

    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

  3. #3
    Join Date
    Oct 2008
    Location
    Southampton, England
    Posts
    61

    Default

    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.
    Christopher Frost,
    Spring Insight and CloudFoundry

  4. #4
    Join Date
    Mar 2010
    Posts
    28

    Default

    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.

  5. #5
    Join Date
    Oct 2008
    Location
    Southampton, England
    Posts
    61

    Default

    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.
    Christopher Frost,
    Spring Insight and CloudFoundry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •