Announcement Announcement Module
Collapse
No announcement yet.
Odd classloading problem can't find class in OSGI bundle Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Odd classloading problem can't find class in OSGI bundle

    I have a bundle A that requires bundle B (aka commonsconfiguration)

    Require-Bundle: com.springsource.org.apache.commons.lang,
    com.springsource.org.hibernate,
    commonsconfiguration

    B is a bundle I have produced via BND that wraps commons-configuration-1.5.jar (not in the repo yet, see https://issuetracker.springsource.com/browse/BRITS-59)

    B is in the usr bundle dir and is shown as ACTIVE on the OSGI console. If I do a bundle command from the console I can see that BUNDLE B is exporting correctly package:

    Exported packages
    org.apache.commons.configuration.event; version="0.0.0"[exported]
    org.apache.commons.configuration.plist; version="0.0.0"[exported]
    org.apache.commons.configuration.reloading; version="0.0.0"[exported]
    org.apache.commons.configuration.interpol; version="0.0.0"[exported]
    org.apache.commons.configuration.web; version="0.0.0"[exported]
    org.apache.commons.configuration.tree.xpath; version="0.0.0"[exported]
    org.apache.commons.configuration; version="0.0.0"[exported]
    org.apache.commons.configuration.beanutils; version="0.0.0"[exported]
    org.apache.commons.configuration.tree; version="0.0.0"[exported]

    Within bundle A I have a bean as follows:

    <bean id="propertiesLoadedViaJDBC"
    class="org.apache.commons.configuration.Configurat ionConverter"
    factory-method="getProperties">
    <constructor-arg>
    <bean
    class="org.apache.commons.configuration.DatabaseCo nfiguration">
    <constructor-arg>
    <ref local="dataSource" />
    </constructor-arg>

    <constructor-arg
    ref="applicationProperties[config.table]" />
    <constructor-arg
    ref="applicationProperties[config.keyColumn]" />
    <constructor-arg
    ref="applicationProperties[config.valueColumn]" />
    </bean>
    </constructor-arg>
    </bean>

    Can anyone think of a reason why I am getting this when I try and deploy bundle A ?

    <SPDE0100E> The class with name 'org.apache.commons.configuration.ConfigurationCon verter', referenced by bean 'propertiesLoadedViaJDBC', could not be loaded by class loader 'PlatformBundleClassLoader: [bundle=commonbasecore_1.0.3]':
    java.lang.ClassNotFoundException: org.apache.commons.configuration.ConfigurationConv erter
    at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClassInternal(BundleLoader.java:481)
    at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClass(BundleLoader.java:397)
    at org.eclipse.osgi.framework.internal.core.BundleLoa der.findClass(BundleLoader.java:385)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClass Loader.loadClass(DefaultClassLoader.java:87)
    at com.springsource.platform.osgi.framework.equinox.P latformBundleClassLoader.loadClass(PlatformBundleC lassLoader.java:134)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
    at org.eclipse.osgi.framework.internal.core.BundleLoa der.loadClass(BundleLoader.java:313)
    at org.eclipse.osgi.framework.internal.core.BundleHos t.loadClass(BundleHost.java:227)
    at org.eclipse.osgi.framework.internal.core.AbstractB undle.loadClass(AbstractBundle.java:1274)
    at org.springframework.osgi.util.BundleDelegatingClas sLoader.findClass(BundleDelegatingClassLoader.java :99)
    at org.springframework.osgi.util.BundleDelegatingClas sLoader.loadClass(BundleDelegatingClassLoader.java :156)

  • #2
    Odd classloading problem can't find class in OSGI bundle

    PS the post meant to say you can correctly see that package "org.apache.commons.configuration" is exported so my bundle B seems to be OK, but A is having a problem finding the class.

    Comment


    • #3
      Odd classloading problem can't find class in OSGI bundle

      Hi Paul,

      Just to be sure I understand your app correctly: is bundle A the 'commonbasecore' bundle with a version of 1.0.3, as mentioned in the SPDE100E error message?

      Thanks,
      Andy

      Comment


      • #4
        Odd classloading problem can't find class in OSGI bundle

        Yep, that will be the one.

        Comment


        • #5
          Odd classloading problem can't find class in OSGI bundle

          Hi Paul,

          Can you use the bundle command in the osgi console to verify the package that has been export/import in bundle A/B?

          In your require bundle example,

          Require-Bundle: com.springsource.org.apache.commons.lang,
          com.springsource.org.hibernate,
          commonsconfiguration

          Is commonsconfiguration the bundle symbolic name of bundle B?

          Thanks,

          Michael

          Comment


          • #6
            Odd classloading problem can't find class in OSGI bundle

            Do you have the commons-configuration-1.5.jar file embedded within bundle b that you produced with BND? If so, have you referenced the embedded JAR in bundle b's Bundle-ClassPath manifest header?

            Comment


            • #7
              Odd classloading problem can't find class in OSGI bundle

              Something very strange has happened in that having upgraded to the latest nightly build of the STS ap eclipse plugin, the error went away. Possibly this was due to a clean re-start of Eclipse and the app server. I don't know, but will get back to you if the problem re-occurs

              Comment

              Working...
              X