Debugging AEM SDK using the OSGi web console
Last update: Tue May 14 2024 00:00:00 GMT+0000 (Coordinated Universal Time)
CREATED FOR:
- Beginner
- Intermediate
- Developer
The AEM SDK鈥檚 local quickstart has an OSGi web console that provides a variety of information and introspections into the local AEM runtime that are useful to understand how your application is recognized by, and functions within AEM.
AEM provides many OSGi consoles, each providing key insights into different aspects of AEM, however the following are typically the most useful in debugging your application.
Bundles
The bundles console lists all the OSGi bundles deployed AEM. Each one represents a bundle, listing the name, version status and actions, including the ability to start and stop. The status is of particular interest as it denotes if the bundle was able to start or not. Active means the bundle started and is ready to go. Resolve means the bundle was stopped. And most interestingly, is the installed state. This indicates that the bundle is installed but not active. Most of the time, this actually means something is preventing the bundle from becoming active, which is usually a problem. And we鈥檒l dig into this in a minute. Clicking into a bundle, we see its details. Exported packages, list the Java packages this bundle exports, or in other words makes available to the rest of AEM, including HTL scripts. Imported packages, lists the Java packages from which this bundle imports classes from other bundles in AEM. Not only does it list the Java packages but also the version or version ranges it requires for those packages, as well as which bundles it鈥檚 importing it from.
Let鈥檚 jump over to another bundle to see how this can be useful. Here鈥檚 an installed bundle. And when we click the enable button, here it means installed rather than turning active. Clicking into it, we see why. It has an unresolved import dependency that鈥檚 preventing it from starting up. To remedy this, we鈥檇 want to make sure we鈥檙e compiling our code against the latest AEM-API Maven dependency. As well as ensure we aren鈥檛 introducing any other custom Maven dependencies into our projects POM files that might be resulting in this unsatisfied import requirement. Okay, let鈥檚 take a look at one more OSGi bundle to see some of the extra detail it can provide. Bundle details lists all OSGi services it exposes along with their service interface and implementing Java classes.
Then comes the OSGi manifest headers, which are the system level description of what鈥檚 in the bundle.
Followed by the OSGi components declared in the bundle along with if they鈥檙e enabled or disabled.
And lastly, any OSGi services this bundle uses. So, as you can see, the bundles console is a powerful tool when it comes to understanding how your OSGi bundle is behaving in the AEM runtime. Note that the information found here is available for AEM as a Cloud Service environments via the cloud-based dev console. However, this exact console is only available on the local AEM runtime. -
The Bundles console is a catalog of the OSGi bundles, and their details, deployed to AEM, along with the ad hoc ability to start and stop them.
The Bundles console is located at:
- Tools > Operations > Web Console > OSGi > Bundles
- Or directly at:
Clicking into each bundle, provides details that help with the debugging your application.
- Validating the OSGi bundle is present
- Validating if an OSGi bundle is active
- Determining if an OSGi bundle has unsatisfied imports preventing it from starting
Components
The components console lists all the OSGi components in AEM. Each row represents an OSGi component listing the name, status along with the ability to start, stop or configure. The status is of particular interest as it denotes if the OSGi component is active or not. A status of active means the OSGi components started and everything鈥檚 good. Satisfied means it can become active. However, nothing else in AEM has used it yet. So it鈥檚 sitting there waiting to become active. No config means it requires an OSGi configuration to be present to become active, but no configuration is present. Therefore it can鈥檛 become active. This is typically set via the configuration policy required flag, in the Java reference annotation. Unsatisfied means the OSGi component cannot become active because it depends on some other OSGi service reference that cannot be satisfied. Usually, this means the reference service doesn鈥檛 exist or that the reference OSGi service itself is unsatisfied.
And disable means that the OSGi component has been explicitly made unavailable. Clicking into a component reveals these details. There鈥檚 all sorts of helpful things to look at here. Default state activation and configuration policy all provide insights into when this OSGi component should become active. Services lists all the Java interfaces, this component exposes itself as an OSGi service. So if you want to leverage this OSGi component in your code, you need to make a reference to the OSGi service interface listed here. The PID is what鈥檚 used as the file name of the OSGi configuration file used to configure this OSGi component. References lists all the OSGi service references this component has, and how those references are defined. If a references are acquired, but unsatisfied, it鈥檒l show up here, and helps you track down why an OSGi component might have the unsatisfied status. And lastly, the properties. These are all the OSGi configuration properties that are bound to, and in use by the OSGi component. This not only provides you with the details of what OSGi configuration state is in use by the OSGi component, but it also provides a nice view of what the OSGi configuration property names are for a particular OSGi component. If you鈥檙e trying to declare your own OSGi configuration file for it. So as you can see, the components console provides a number of helpful insights into the OSGi components in AEM. Remember that if none of your OSGi bundles or share components are listed here, it typically means that your OSGi bundle wasn鈥檛 installed or was unable to become active for some reason. Note that the information found in this console is available for AEM as a cloud service environment via the cloud-based dev console. However, it鈥檚 this exact console is only available for the local AEM runtime. -
The Components console is a catalog of all the OSGi components deployed to AEM, and provides a all information about them, from their defined OSGi component life cycle, to what OSGi services they may reference to
The Components console is located at:
- Tools > Operations > Web Console > OSGi > Components
- Or directly at:
Key aspects that help with the debugging activities:
- Validating the OSGi bundle is present
- Validating if an OSGi bundle is active
- Determining if an OSGi bundle has unsatisfied imports preventing it from starting
- Obtaining the component鈥檚 PID, in order create OSGi configurations for them in Git
- Identifying OSGi property values bound to the active OSGi configuration