4 Replies Latest reply on Sep 6, 2012 6:05 AM by thomas.diesler

    No bundle notifications on shutdown

    brad-uk

      Hi All,

       

      I'm experiencing an issue where my blueprint services with a "destroy-method" attribute are not shutdown as required when I do a crtl+c in the console. I've done some debugging and I think the cause is that the blueprint service is not being passed the bundle notification STOPPED when my bundle is uninstalled. Subsequently, the blueprint extender service is shutdown and it interrogates my bundle for some information (as it thinks it is still installed) at which point the OSGI core correctly throws the IllegalStateException. If I leave the server running and just uninstall the bundle then the destroy-method is called, so it would appear to be an issue during server shutdown only.

       

      Looking at the code for osgi-framework-core it seems there is a JVM shutdown hook in BundleManager which is used to flag the framework as not active in the method isFrameworkActive(). I think this is stopping the notification being passed to the blueprint service. I've tried removing the hook and that does allow my destroy-method to be called as required, although I get some other errors due to the bundle events being out of sequence.

       

      So, I guess my question is - is this behaviour expected? I couldn't see anything in the OSGI specs to say bundle notifications should be disabled on shutdown.

       

      We are currently using AS 7.1.1 with core-framework 1.1.8. I tried it with 7.1.2/1.3.0 and it appeared to show the same result.

       

      Thanks,

      Brad.