この会話は、活動がないためロックされています。新しい投稿を作成してください。
この会話は、活動がないためロックされています。新しい投稿を作成してください。
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
解決済! 解決策の投稿を見る。
See this video - it steps you though this - most likily cause is you did not configure Sling Mapping properly - see this article and video:
表示
返信
いいね!の合計
Are you sure you have to reference for the resolverFactory?
表示
返信
いいね!の合計
If there is no @Reference
private ResourceResolverFactory resolverFactory;
Then there is no access to the class ResourceResolverFactory.
All the examples also use @Reference
private ResourceResolverFactory resolverFactory;
表示
返信
いいね!の合計
This works in AEM 6 - here is the output in the AEM 6 Touch UI:
[img]Sling.png[/img]
If you want to have a connect session with me and we can figure out what is happening on your end, please let me know.
表示
返信
いいね!の合計
Thank you for the offer. What time tomorrow (GMT) would suit you and how would we conduct communication?
Regards
Clive
表示
返信
いいね!の合計
Hi Clive,
It would be great if you can put down the solution which you did to resolve this issue.
表示
返信
いいね!の合計
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
表示
返信
いいね!の合計
Hi Clive,
I am facing a similar issue. This line throws a NullPointerException:
ResourceResolver resourceResolver =resolverFactory.getAdministrativeResourceResolver(null);
Any solution yet?
Thanks
表示
返信
いいね!の合計
"The method getServiceResourceResolver(Map<String,Object>) is undefined for the type ResourceResolverFactory
and
SUBSERVICE cannot be resolved or is not a field."
This is due to your api version didn't contain SUBSERVICE field. Please upgrade your "org.apache.sling.api" version in the maven dependency and compile your code against it.
Hope this helps.
I'm facing the similar issue . Getting "java.lang.NullPointerException: null" for getServiceResourceResolver(param); Any Help?
表示
返信
いいね!の合計
See this video - it steps you though this - most likily cause is you did not configure Sling Mapping properly - see this article and video:
表示
返信
いいね!の合計
I tried complete video step by step But still facing the issue. Its showing ResourceResolverFactory is Null.
表示
返信
いいね!の合計
I also change the dependency version of "org.apache.sling.api". Still no clue.
表示
返信
いいね!の合計
In sling mapping, did you use symbolic bundle name? And you used a system user And granted the correct permissions?
表示
返信
いいね!の合計
I used the symbolic bundle as showing in the video. I used general user instead of system user because its AEM 6.0. The issue is with the ResourceResolverFactory for me. its showing null. So I tried to get it through the Bundle Context and its resolved. Thank you.
表示
返信
いいね!の合計