Hi All,
I am trying to get the session and resource resolver in a standalone Java code outside of AEM.
I am able to get the session but unable to get the resource resolver from the session.
Facing Null pointer exception.
Attaching screenshots for reference.
getting below exception , please note that the session is not null.
Any help will be appreciated.
Thanks,
Sanjana
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @sanjanas3080058,
From the code snippet shared and name of Java class file(ImportAssetsToDam), could assume that are trying to Import Assets to DAM from Standalone Java code.
If it is for the reason of one time activity, you can make use of Groovy Scripts where accessing objects/APIs are ease or you can write a OSGI Servlet/ Service outside of project code base, so that same can be started/stopped independently.
Please do share the reason/need for writing this as Standalone Java code.
Accessing Sling Service APIs(ResourceResolverFactory) outside AEM is an overhead. Explanation justifying this on https://stackoverflow.com/questions/41708758/aem-sling-how-to-create-resourceresolverfactory-in-a-st...
You should use the getServiceResourceResolver() to get the resource resolver from Resource Resolver Factory.
Here is the sample code to get the service resource resolver.
https://one-inside.com/aem6-resourceresolver-access-in-services/
Thanks!
Can you let me know the use-case of why you might need the resource resolver from a non-AEM application? Because the javax.jcr.Session should allow CRUD (Create Read Update Delete) in your Java Content Repository.
Documentation here - https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/access-jcr.html?la...
Views
Replies
Total Likes
Hi @sanjanas3080058,
From the code snippet shared and name of Java class file(ImportAssetsToDam), could assume that are trying to Import Assets to DAM from Standalone Java code.
If it is for the reason of one time activity, you can make use of Groovy Scripts where accessing objects/APIs are ease or you can write a OSGI Servlet/ Service outside of project code base, so that same can be started/stopped independently.
Please do share the reason/need for writing this as Standalone Java code.
Accessing Sling Service APIs(ResourceResolverFactory) outside AEM is an overhead. Explanation justifying this on https://stackoverflow.com/questions/41708758/aem-sling-how-to-create-resourceresolverfactory-in-a-st...
Hi @Vijayalakshmi_S,
Thanks for your reply. As you have rightly pointed out , I am trying to import the assets from S3 Bucket to AEM using a AWS lambda function. I was trying to explore the Asset Manager API functionality to upload assets to DAM outside of AEM. For this I would need the resource resolver to adapt to AssetManager class and hence was trying to fetch the resource resolver from the session.
Views
Replies
Total Likes
Hi @sanjanas3080058,
Thanks for the inputs.
Is it possible for you to provide details on
Views
Replies
Total Likes
Rightly pointed out by @BrianKasingli that it is supposed to be Jcr API so the concept of ResourceResolver is not applicable as it uses sling API which is higher abstract level. You need to use the node level operations using JCR node interface.