Skip to main content
Level 4
May 27, 2017
해결됨

Not able to inject ResouceResolverFactory

Hi,

Not able to inject resouceresolverfactory in following code.

I created an interface

public interface WriteService{

    public void getSession();

{

And a class which implemented an interface

@Component(immediate=true) @Service(value = WriteSerive.class) public class WriteServiceImp  implements WriteService { @Reference private ResourceResolverFactory resourceFactory; @Override public void getSession(){ try{ Map<String,Object> paramMap = new HashMap<String,Object>(); paramMap.put(ResourceResolverFactory.SUBSERVICE, "connectSession"); ResourceResolver rr = null; rr = resourceFactory.getServiceResourceResolver(paramMap); Sessionsession = rr.adaptTo(Session.class); } catch(Exception e){ } }

 

Any Suggestion?

Thanks in advance

이 주제는 답변이 닫혔습니다.
최고의 답변: smacdonald2008

Watch the video here - we do a step by step of everything you need:

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

You need to reference the system user and make sure you specify the symbolic bundle name as mentioned in the video

18 답변

umeshj24393작성자
Level 4
May 29, 2017

Actually,

At this line, 

  1. rr = resourceFactory.getServiceResourceResolver(paramMap);

It throws java.lang.NullPointerException.

I think resourceFactory variable is not injected in osgi bundles..

antoniom5495929
Level 7
May 30, 2017
        Have you tried to debug? Are you sure that resourceResolverFactory is null? I suggest you to debug or insert a log in order to be sure that this is not related to wrong configuration of user mapper or user amendement service..
umeshj24393작성자
Level 4
May 30, 2017

Yes,I tried to debug and resourceResolverFactory is null throw java.lang.NullPointerException: null

Feike_Visser1
Adobe Employee
Adobe Employee
May 30, 2017

What do you see here? 

/system/console/components

There should be a reason why the dependency can't be injected

smacdonald2008
Level 10
May 30, 2017

Post a Screen shot of your OSGI SLING MAPPING - i suspect issue is there. 

umeshj24393작성자
Level 4
June 2, 2017

com.adobe.connect.osgi.service.connect-osgi-service:connectSession=connect

where connect is serviceuser.

smacdonald2008
Level 10
June 2, 2017

Watch the video here - we do a step by step of everything you need:

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

You need to reference the system user and make sure you specify the symbolic bundle name as mentioned in the video

umeshj24393작성자
Level 4
June 5, 2017

In /system/console/componenets

What i observed that:-

ccom.adobe.ClassName  and its status is Satisfied