Expand my Community achievements bar.

Adobe Summit 2025: AEM Session Recordings Are Live! Missed a session or want to revisit your favorites? Watch the latest recordings now.
SOLVED

OSGi bundle lifecycle

Avatar

Level 1

Hi all,

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

AEM BlogsLinkedIn


View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

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

AEM BlogsLinkedIn


Avatar

Community Advisor

@SantoshSai  even I learned this thing from your blogs and videos   

Thanks for the amazing content.

Avatar

Level 4

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 

 

Avatar

Level 2

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-osg...

 

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!