Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-4792

[SCR] Handle Errors on component initialization

    XMLWordPrintableJSON

Details

    Description

      During component initialization the component implementation class is loaded. If the class or one of its dependencies cannot be properly loaded a ClassDefNotFound error can be thrown.

      This error bubbles up from BundleComponentActivator.initialEnable to the AbstractExtender.createExtension method, where it is logged. The problem with this is, that the BundleComponentActivator has registered all the components of the bundle with the ComponentRegistry but when the error is thrown, the BundleComponentActivator is not registered in Activator's m_componentBundles map.

      So, when the bundle is stopped, the components registered with the ComponentRegistry stay registered and will never be cleaned away.

      The simple fix is to catch Throwable in the BundleComponentActivator.initialEnable method and log it. The single component failing to load will stay inactive but the rest of the component registration will continue unaffected.

      Background: We have a situation where a bundle is compiled against an API bundle whose exported API is not properly versioned. So the OSGi framework happily wires the bundle to the older API bundle version but one of the components fails to load due to missing API.

      Attachments

        Activity

          People

            fmeschbe Felix Meschberger
            fmeschbe Felix Meschberger
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: