OSGi bundle lifecycle | Community
Skip to main content
Level 2
May 2, 2025
Solved

OSGi bundle lifecycle

  • May 2, 2025
  • 3 replies
  • 702 views

Hi all,

Is there any detailed source where I can understand the different states of the OSGi bundle lifecycle more clearly?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SantoshSai

Hi @ethanro5,

I think, a great place to start is the official OSGi specification, which explains the bundle lifecycle in depth.I have also provided a detailed explanation with a practical demo in the blog post “OSGi Bundle Lifecycle”.. where you will understand below points: 

  1. Lifecycle
  2. Bundle Lifecycle : Resolved
  3. Lifecycle : Starting
  4. Lifecycle : Active and Beyond
  5. Bundle Class Loading
  6. Bundle Fragments
  7. Summary

For a more practical approach, the Apache Felix documentation also offers insights into how bundles behave within an OSGi container like AEM.

Hope that helps!

3 replies

SantoshSai
Community Advisor
SantoshSaiCommunity AdvisorAccepted solution
Community Advisor
May 2, 2025

Hi @ethanro5,

I think, a great place to start is the official OSGi specification, which explains the bundle lifecycle in depth.I have also provided a detailed explanation with a practical demo in the blog post “OSGi Bundle Lifecycle”.. where you will understand below points: 

  1. Lifecycle
  2. Bundle Lifecycle : Resolved
  3. Lifecycle : Starting
  4. Lifecycle : Active and Beyond
  5. Bundle Class Loading
  6. Bundle Fragments
  7. Summary

For a more practical approach, the Apache Felix documentation also offers insights into how bundles behave within an OSGi container like AEM.

Hope that helps!

Santosh Sai
partyush
Community Advisor
Community Advisor
May 3, 2025

@santoshsai  even I learned this thing from your blogs and videos 🙂  

Thanks for the amazing content.

Level 4
May 2, 2025

Hi @ethanro5 ,

 

Understanding the OSGi bundle lifecycle is crucial to knowing how OSGi components operate. The main stages are:

 

  1. Installed:
    The bundle is deployed into the OSGi container, but its dependencies haven't been resolved yet.
  2. Resolved:
    All the bundle's dependencies are met, and it's ready to be started.
  3. Starting:
    The bundle is in the process of being activated, executing its activator code if specified.
  4. Active:
    The bundle is fully initialized, running, and ready to be used, with services registered.
  5. Stopping:
    The bundle is being stopped, cleaning up resources, and transitioning back to the Resolved state.
  6. Uninstalled:
    The bundle has been removed from the OSGi container and is no longer active.

You can refer to the explanations provided in the links below:

OSGI Bundle LifeCycle-1 

OSGI Bundle LIfeCycle-2 

 

pranayr
Level 2
May 2, 2025

Hi @ethanro5 

 

I find this article very useful for anyone who needs to understand OSGi bundle lifecycle more clearly : 

https://medium.com/aem-architect-developer-business-practitioner/osgi-bundle-lifecycle-deploying-osgi-bundles-with-maven-and-troubleshooting-tips-6e4efd7b4ea6

 

And also summing up the stages here too :

 

  1. Installed: When you deploy a bundle, it’s in the “Installed” stage. It’s available to the system, but not running yet.
  2. Resolved: After OSGi checks that all bundle requirements are met, the bundle becomes “Resolved.” Dependencies are resolved, but it’s still not active.
  3. Starting: The bundle enters the “Starting” stage when it’s being activated. It executes an activator code if specified.
  4. Active: Once the bundle is fully initialized and running, it reaches the “Active” stage. Services are registered, and it functions properly.
  5. Stopping: If you stop the bundle or there are changes in dependencies, it enters the “Stopping” stage to clean up resources.
  6. Uninstalled: Finally, the bundle is “Uninstalled” when it’s removed from the system.

 

Hope this helps!