Search code examples
javaosgiequinox

How can I debug OSGI classloader issues in Equinox?


I am trying to create OSGI bundles for RestEasy 2.2.1.GA. However, my test client bundle for RestEasy bundles fails when it tries to insantiate a specific type.

This problem is specific to Equinox container, but I got stuck when trying to figure out what went wrong. I can't narrow down the problem to the actual type that is causing the issue. Probably a field of the problematic class with another type, or some other type in the inheritance chain is inaccassible, but which one?

Is there a way to get more information about the problem? A class not found exception does not help me at this point. How can I discover the root of the problem? In the compile time, Eclipse does not complain about finding the problematic type, and all deployed plugins are reported as "resolved" under equinox console.


Solution

  • You need to have an idea what's happening:

    1. Check where's the ClassNotFoundException is happening. It points (in most cases), which bundle cannot load the class. Be aware of some bundles, being extenders, which try to load classes on behalf of other bundles.

    2. Find where the class is located using Equinox console

    3. By now you should have pretty good understanding of how the things are supposed to work. Now, you need to find out why they don't work. Unfortunately, I couldn't find good debugging tool for inspecting the resolver's work. You can try to deduce your problem (if it is in the resolver) using the extensive debug information, logged by org.eclipse.osgi, when enabled.

      What org.eclipse.osgi debug options are available? (might not be up to date)

      How to enable them