AMS Sling models not instantiated in AEMaaCS | Community
Skip to main content
Level 5
September 3, 2025
Solved

AMS Sling models not instantiated in AEMaaCS

  • September 3, 2025
  • 5 replies
  • 1751 views

Hi,

We are moving from AMS to AEMaaCS but midway we realized that AMS license is going to expire coming November. We are planning to lift and shift few components from AMS to AEMaaCS temporarily while part of team is working on new component creation on AEMaacs.

AMS code repo is on Maven archetype version 17 or 19 and AEMaaCS on recent version.

I have created a package of templates, components, page components, clientlibs, bundle from AMS environment and installed it on AEMaaCS instance along with content but while loading I see below error

03.09.2025 19:43:41.176 *ERROR* [[0:0:0:0:0:0:0:1] [1756908818438] GET /content/my-company/en-us/home/articles.html HTTP/1.1] com.day.cq.wcm.core.impl.WCMDeveloperModeFilter Error during include of SlingRequestPathInfo: path='/content/my-company/en-us/home/articles/jcr:content', selectorString='null', extension='html', suffix='null' org.apache.sling.scripting.sightly.SightlyException: Identifier com.core.aem.core.components.model.Container cannot be correctly instantiated by the Use API at org.apache.sling.scripting.sightly.impl.engine.extension.use.UseRuntimeExtension.call(UseRuntimeExtension.java:73) [org.apache.sling.scripting.sightly:1.4.28.140]

I am unable to see my sling models from AMS code here http://localhost:4502/system/console/status-slingmodels. Here is the configuration of AMS core/pom.xml for build plugin org.apache.sling

<Sling-Model-Packages> com.core.aem </Sling-Model-Packages>

 Any suggestions on the solution to resolve this error?

Bottomline is, I would like to use AMS components, bundle on AEMaaCS for a short period of time and remove this technical debt very soon.

Best answer by MukeshYadav_

Thanks @mukeshyadav_ 

The exception I see now is resourceResolver object is null in sling models even though it is injected properly 

@SlingObject private ResourceResolver resourceResolver;@Model(adaptables = { Resource.class, SlingHttpServletRequest.class }, defaultInjectionStrategy = DefaultInjectionStrategy.REQUIRED) public class CorePage {

Any suggestions on how to fix null pointer exceptions for injected objects which were working fine on AEM 6.5.17?

Also, any suggestions on how to upgrade the maven archetype of AEM 6.5 repository?


Hi @srikanthpo3 ,

You may use repository modernizer tool, as discussed in reference link for archetype 24.
Reference https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/migration-journey/refactoring-tools/repo-modernizer

https://ms-29.com/aem/cloud/repository-modernizer-update-archetype

As for as null pointer you may try @ScriptVariable and better to have injection Optional if possible. However it all depends on requirement

 @ScriptVariable
    private ResourceResolver resolver;

Reference https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/obtaining-resourceresolver-in-sling-model/td-p/388288
Thanks

5 replies

SantoshSai
Community Advisor
Community Advisor
September 3, 2025

Hi @srikanthpo3,

I hope you verified the bundle is active?

Santosh Sai
Level 5
September 3, 2025

Hi @santoshsai ,

Yes the bundle is active

Level 5
September 3, 2025

Not limited the current approach, If there is any other approach which solves the problem of moving AMS components from AMS to AEMaaCS, please suggest.

MukeshYadav_
Community Advisor
Community Advisor
September 3, 2025

Hi @srikanthpo3 ,

There are several reasons why Use API might not be getting instantiated. Here are a few things you can check:

  1. Try using "optional" as the injection strategy.

  2. Some configurations might prevent the service from being injectable. Please verify if any service is being injected.

PS: Search for ".java" in the error log to pinpoint the exact sling model and line number causing the issue.

Thanks!

Level 5
September 4, 2025

Hi @mukeshyadav_ 

We are using optional injection strategy, here is the signature

@Model(adaptables = { Resource.class, SlingHttpServletRequest.class }, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL, adapters = Container.class, resourceType = ContainerImpl.RESOURCE_TYPE) public class ContainerImpl implements Container {
giuseppebaglio
Level 10
September 5, 2025

Hi @SrikanthPo3

Sometimes, other Sling models injected as dependencies can cause issues. Please try removing any other Sling models to see if the application starts correctly. If it does, this indicates that the problem lies with another model. If you still don’t find any hints, I recommend commenting out all fields with annotations, then building and installing the model to see if it works. Once you have a functioning model, you can gradually reintroduce each annotated field to identify the root cause of the issue.

Level 5
September 8, 2025

Hi @giuseppebaglio 

I tried to do the following

  1. Install AMS bundle in Felix console - it is active in status
  2. Install CRX package components and templates from /apps/core/components and /apps/{mycompany}/components
  3. Install CRX package of content

I did not install the snapshot or versioned ui.apps and ui.configs package of AMS code as it corrupted my local instance with an error related to versioned clientlibs

MukeshYadav_
Community Advisor
MukeshYadav_Community AdvisorAccepted solution
Community Advisor
September 15, 2025

Thanks @mukeshyadav_ 

The exception I see now is resourceResolver object is null in sling models even though it is injected properly 

@SlingObject private ResourceResolver resourceResolver;@Model(adaptables = { Resource.class, SlingHttpServletRequest.class }, defaultInjectionStrategy = DefaultInjectionStrategy.REQUIRED) public class CorePage {

Any suggestions on how to fix null pointer exceptions for injected objects which were working fine on AEM 6.5.17?

Also, any suggestions on how to upgrade the maven archetype of AEM 6.5 repository?


Hi @srikanthpo3 ,

You may use repository modernizer tool, as discussed in reference link for archetype 24.
Reference https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/migration-journey/refactoring-tools/repo-modernizer

https://ms-29.com/aem/cloud/repository-modernizer-update-archetype

As for as null pointer you may try @ScriptVariable and better to have injection Optional if possible. However it all depends on requirement

 @ScriptVariable
    private ResourceResolver resolver;

Reference https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/obtaining-resourceresolver-in-sling-model/td-p/388288
Thanks

kautuk_sahni
Community Manager
Community Manager
September 12, 2025

@srikanthpo3 Quick follow-up! Were you able to get this issue sorted out? If you did, please consider posting the solution you used so others can learn from it. And if any of the replies above were helpful—whether they fully solved your problem or just pointed you toward the right fix—marking one as accepted helps future community members find solutions more easily. Closing the loop here makes a real difference for everyone.

Kautuk Sahni
Level 5
September 12, 2025

Hi @kautuk_sahni 

I could not solve the issue yet, am still working on it and looking for guidance.