Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Error while reading DAM

Avatar

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

Avatar

Correct answer by
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

Avatar

Correct answer by
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


Avatar

Level 1
was trying out with getAdministrativeResourceResolver(null),

Avatar

Community Advisor
Try using this, as we are accessing some file placed in DAM we do need a authenticated service user to do so.

Avatar

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