AEM Publish: Excessive log errors from Page Sling Model on 404 product pages
This article explains how to address excessive error log entries related to the Page Sling Model when invalid product page URLs return 404 responses on Adobe Experience Manager (AEM) Publish instances.
Description description
Environment
Adobe Experience Manager (AEM) Publish instance (all versions)
Issue/Symptoms
-
Each invalid product page request generates a full stack trace in the logs.
-
Log entries include errors such as:
Identifier com.adobe.cq.wcm.core.components.models.Page cannot be correctly instantiated by the Use APIjavax.script.ScriptException: org.apache.sling.scripting.sightly.SightlyException: Identifier com.adobe.cq.wcm.core.components.models.Page cannot be correctly instantiated by the Use API
Example log excerpt:
at org.apache.sling.scripting.sightly.impl.engine.SightlyScriptEngine.eval(...)
at libs.cq.Page.Page__002e__jsp._jspService(Page__002e__jsp.java:145)
Example URL: https://www.example.com/products/product-page.invalid-id
Cause
These errors occur because the core Page Sling Model (com.adobe.cq.wcm.core.components.models.Page) is instantiated in contexts where required dependencies, such as ComponentContext, are unavailable, especially during error handling for invalid product pages on Publish. This behavior causes instantiation failures and excessive error logging.
Resolution resolution
Follow these steps to resolve the issue:
-
Review your codebase, typically in
ui.apps, for any HTL references to the Page Sling Model, such as:data-sly-use.page="com.adobe.cq.wcm.core.components.models.Page"- Any direct use of
com.adobe.cq.wcm.core.components.models.Pagein custom page or error components.
-
Refactor or remove direct instantiation of the Page model:
- Remove or refactor usages so that custom components do not instantiate the Page model directly through
data-sly-use. - If you need page-level information, implement a dedicated Sling Model by using the standard
com.day.cq.wcm.api.Pageinterface. For example:
code language-none @Model(adaptables = SlingHttpServletRequest.class) public class CustomPageModel { @Inject private Page currentPage; // com.day.cq.wcm.api.Page // Getters... } - Remove or refactor usages so that custom components do not instantiate the Page model directly through
-
In HTL, reference your custom model instead of the core Page model.
-
Deploy the updated implementation to a staging environment.
-
Validate that invalid product URLs still return 404 responses and that the excessive log errors no longer occur.
-
If similar errors persist, collect updated logs and review the error-handling flow for additional adjustments.