Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The OSGi framework achieves much of its power through its class-loading architecture, which is more complex than the usual class loading of a standard Java application. Thus, it should come as no surprise that class-loading problems, popularly known as class hell, can be more prevalent. In the next few sections, we’ll go through some of the possible problems you may run into and see how they can be addressed.
The first problem you’re likely to run into is a ClassNotFoundException as a result of having forgotten to import its package using the Import-Package header. This is the most common problem you’ll run into in OSGi. The good news is that it’s easily spotted and corrected. But can you avoid it? Yes, you could automate the generation of the MANIFEST file of a bundle. The tool would have to introspect the Java code within the bundle, checking for all the import class statements. Then, the tool would need to generate an Import-Package for each package whose class is being imported.