using getAdministrativeResourceResolver(null) in AEM 6 | Community
Skip to main content
Level 6
Oct 16, 2015 2:27 AM UTC
Solved

using getAdministrativeResourceResolver(null) in AEM 6

I am trying to use the following line of code from http://helpx.adobe.com/experience-manager/using/using-sling-apis.html

ResourceResolver resourceResolver =resolverFactory.getAdministrativeResourceResolver(null); //line 82

 

but I get java.lang.NullPointerException
    at shoprite.holdings.impl.FetchStores.jcrStoresUptodate(FetchStores.java:82)

    at shoprite.holdings.impl.FetchStores.<init>(FetchStores.java:66)

    at shoprite.holdings.impl.StoreLocatorImpl.getStores(StoreLocatorImpl.java:26)

    at shoprite.holdings.TestGetStores.main(TestGetStores.java:14)

 

I have tried to replace this with the following code from the blog "AEM6: ResourceResolver access in services" http://cqblog.inside-solutions.ch/category/cq5/.

Map<String, Object> param = new HashMap<String, Object>();
        param.put(ResourceResolverFactory.SUBSERVICE, "readService");
        ResourceResolver resolver = null;
        try {
            resolver = resolverFactory.getServiceResourceResolver(param);

 

However I get the following errors

The method getServiceResourceResolver(Map<String,Object>) is undefined for the type ResourceResolverFactory

and 

SUBSERVICE cannot be resolved or is not a field.

From this I am assuming that the version of ResourceResolver I am using is not concurrent. I am definitely on version 6 of AEM. I am also not sure why the code example from AEM 5.6 ResourceResolver resourceResolver =resolverFactory.getAdministrativeResourceResolver(null); gives me a NullPointerException

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
smacdonald2008
smacdonald2008Accepted solution
Level 10
Jun 7, 2017 1:45 PM UTC

See this video - it steps you though this - most likily cause is you did not configure Sling Mapping properly - see this article and video:

Scott's Digital Community: Querying Adobe Experience Manager 6 data using the Sling getServiceResourceResolver method

14 replies

Level 6
Oct 16, 2015 2:27 AM UTC

Thank you for the offer. What time tomorrow (GMT) would suit you and how would we conduct communication?

 

Regards

 

Clive

Translate
Lokesh_Shivalingaiah
Level 10
Oct 16, 2015 2:27 AM UTC

Hi Clive,

It would be great if you can put down the solution which you did to resolve this issue.

Translate
Level 6
Oct 16, 2015 2:27 AM UTC

I think I may have written a response incorrectly.

 

No solution yet. 

 

I am going to update to SP1 in AEM and see if that resolves it. 

 

If I find a solution I will post it on here.

 

 

Apologies

Translate
New Participant
Oct 16, 2015 2:27 AM UTC

Hi Clive,

I am facing a similar issue. This line throws a NullPointerException:

ResourceResolver resourceResolver =resolverFactory.getAdministrativeResourceResolver(null);

Any solution yet?

Thanks

Translate