Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Error while reading DAM

lk08
Level 1
Level 1

When I try reading JSON file from DAM using resolver factory I am getting null pointer.

 

Tried many ways. I am using servlet call.

 

1 Accepted Solution
Nikhil-Kumar
Correct answer by
Community Advisor
Community Advisor

@lk08 

Try reading it using service user. 
You can create a systme user by going to /crx/exlporer and then later assign the read/write permissions in /useradmin

Nikhil_Kumar_AEM_0-1598344990391.png

 


Once you are done creating the user, try the resolverFactory code to get the resource resolver and then resource out of it.

Map<String, Object> param = new HashMap<>();
param.put(ResourceResolverFactory.SUBSERVICE, "serviceUser");
ResourceResolver resourceResolver = resolverFactory.getServiceResourceResolver(param);

Happy Coding!!


Thanks,
Nikhil


View solution in original post

4 Replies
Nikhil-Kumar
Correct answer by
Community Advisor
Community Advisor

@lk08 

Try reading it using service user. 
You can create a systme user by going to /crx/exlporer and then later assign the read/write permissions in /useradmin

Nikhil_Kumar_AEM_0-1598344990391.png

 


Once you are done creating the user, try the resolverFactory code to get the resource resolver and then resource out of it.

Map<String, Object> param = new HashMap<>();
param.put(ResourceResolverFactory.SUBSERVICE, "serviceUser");
ResourceResolver resourceResolver = resolverFactory.getServiceResourceResolver(param);

Happy Coding!!


Thanks,
Nikhil


View solution in original post

lk08
Level 1
Level 1
was trying out with getAdministrativeResourceResolver(null),
Nikhil-Kumar
Community Advisor
Community Advisor
Try using this, as we are accessing some file placed in DAM we do need a authenticated service user to do so.
Veena_Vikram
Community Advisor
Community Advisor
@lk08 getAdministrativeResourceResolver(null), is a deprecated way of getting resource resolver and will not work anymore. So please follow the method nikhil has mentioned