Search code examples
javaosgiclassloaderequinoxclassnotfoundexception

Equinox: classes correctly exported and imported by bundles, still getting ClassNotFoundException


I came upon the following obstacle whilst developing in OSGi. One set of bundles, responsible for persistence, uses the com.mysql.jdbc.Driver class, offered by another (Springsource EBR provisioned) bundle. In another bundle I'm configuring the Quartz scheduler library to use a database as a jobstore. This is also done using the MySQL driver. Upon running however, I get a ClassNotFoundException. This is strange, since the persistence still functions correctly. Even more strange, when I try to manually load the class, using Class.forName("com.mysql.jdbc.Driver") it is loaded correctly, implying that the class is indeed available for loading.

Coincidence or not, the same seems to be happening with Drools... I repackaged some of the latest Drools jars as OSGi bundles, deployed them and when running again the ClassNotFoundException pops up. In both cases all supplier bundles are added to the required bundles in the manifest.

Does this weird issue ring any bells? I'd be happy to hear about it...


Solution

  • This seems to have been a problem concerning the classloading within Equinox. I tried fixing this using the DynamicImport-Package and Eclipse-BuddyPolicy headers, but without much success. Eventually I fixed this by repackaging the latest version of Quartz as a bundle myself, adding the MySql jar in the bundle. It's not the prettiest or most elegant solution, but it will have to do for now. In case anybody could tell me more about the classloading, feel free to reply!