Sling Models with jakarta.annotation.PostConstruct fail on AEM 6.5 LTS

Sling Models on AEM 6.5 LTS fail to initialize when they use jakarta.annotation.PostConstruct which prevents post-construct logic from executing and disrupts component behavior. Updating the models to use javax.annotation.PostConstruct restores proper initialization and expected component functionality.

To resolve the issue, revert Sling Models to javax.annotation.PostConstruct.

Description description

Environment

  • Adobe Experience Manager (AEM) Managed Services
  • AEM 6.5 LTS with Sling Models

Issue/Symptoms

  • Sling Model @PostConstruct methods don’t execute after switching from jakarta.annotation.PostConstruct.
  • Components that rely on post-construct logic fail to render or behave correctly.
  • Models deploy sucessfully, but initialization logic doesn’t run.

Root Cause

AEM 6.5 LTS does not fully support Sling Models using the jakarta.annotation namespace. The Sling Models implementation recognizes only javax.annotation.PostConstruct, so jakarta.annotation.PostConstruct methods are not executed during model initialization.

Resolution resolution

Steps to resolve:

  1. Update all Sling Model classes to use javax.annotation.PostConstruct instead of jakarta.annotation.PostConstruct.
  2. Remove all jakarta.*imports related to @PostConstruct from all Sling Model classes.
  3. Review your project dependencies (for example, pom.xml) and confirm that only javax dependencies are used for annotations relevant to Sling Models.
  4. Rebuild the project to ensure the dependency and import changes are correctly applied.
  5. Deploy the updated code and verify that the bundle containing the Sling Models is in the Active state in the /system/console/bundles.
  6. Verify that all Sling Models classes are listed in /system/console/status-slingmodels.
  7. Confirm that @PostConstruct methods are invoked successfully, and components behave as expected.

Notes:

  • AEM 6.5 LTS does not support Sling artifacts migrated to the jakarta.* namespace, including jakarta-based @PostConstruct.
  • This behavior aligns with reference implementations such as the AEM WKND Sites Project, which continues to use javax.annotation.PostConstruct on AEM 6.5 LTS.
recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f