Clearing Up Class Loading Problems in OSGi Based Systems
A class loading architecture is a foundational element that enables the modularity of OSGi. Each OSGI bundle has a separate class loader, which it uses to share or hide classes and resources. However, within OSGI, the bundles has to delegate class loading to other bundles, and therefore, OSGI class loading is much different from normal java class loading. Due to these complexities in OSGi, there are many ways a developer can go wrong when developing OSGi bundles. Moreover, since the cause of these problems are not always obvious, diagnosing and determining a solution to class loading problems can be very time consuming. Most of these problems occur due the incorrect wiring between exporters and importers of packages which can be tedious to resolve.
In this talk, I will discuss various class loading problems and how to avoid them using real world examples. Due to the excessive involvement of developing OSGI based systems(WSO2 Carbon - Open source enterprise middleware), I’ve faced many real world class loading issues. Guiding OSGi developers on how to solve common class loading issues as well as discussing about the best practises, they can apply to avoid these issues will be important for developers. Therefore starting from a brief introduction to the class loading architecture in OSGi, I will explain how to diagnose and resolve some common OSGI problems ranging from simple errors like ClassNotFoundException, NoClassDefFoundError to more challenging problems such as ClassCast exceptions and loader constraint violations.