3 Replies Latest reply: May 3, 2011 4:06 AM by Thomas Diesler RSS

    Logging bundle resolution errors

    Thomas Diesler Master

      The proposed resolution to JBOSGI-439 is


                  try {
                      ResolverPlugin resolverPlugin = getFrameworkState().getResolverPlugin();
                      return true;
                  } catch (BundleException ex) {
                      if (fireEvent == true) {
                          FrameworkEventsPlugin eventsPlugin = getFrameworkState().getFrameworkEventsPlugin();
                          eventsPlugin.fireFrameworkEvent(this, FrameworkEvent.ERROR, ex);
                      } else {
                          // Make sure the reason for not resolving doesn't get lost, so log it.
                          log.errorf(ex, "Could not resolve bundle: %s", this);
                      return false;


      This however negates the purpose of the 'fireEvent' flag in terms of logging.


      We have a number of places were we explicitly turn off logging/error events when resolution fails


      [tdiesler@localhost jbosgi-framework]$ git grep "ensureResolved(false)"
      core/src/main/java/org/jboss/osgi/framework/internal/HostBundleFallbackLoader.java:            if (bundle.ensureResolved(false) == false)
      core/src/main/java/org/jboss/osgi/framework/internal/HostBundleRevision.java:        if (getBundleState().ensureResolved(false) == false)
      core/src/main/java/org/jboss/osgi/framework/internal/HostBundleRevision.java:        if (getBundleState().ensureResolved(false)) {
      core/src/main/java/org/jboss/osgi/framework/internal/HostBundleState.java:            if (ensureResolved(false) == false)


      The most obvious one is for dynamic imports when we iterate over installed bundles and try to resolve them silently in order to check whether the import can be sattisfied.


      Bundle resolution is triggered by


      • Bundle start
      • Bundle class load
      • Bundle resource load
      • Dynamic and optional imports


      The rational with the code was that the caller decides whether an event is fired. In case of an error event the cause would be logged.