Not able to inject ResouceResolverFactory | Community
Skip to main content
New Participant
May 27, 2017
Solved

Not able to inject ResouceResolverFactory

  • May 27, 2017
  • 18 replies
  • 5250 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by 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 replies

New Participant
June 5, 2017

In /system/console/componenets

What i observed that:-

ccom.adobe.ClassName  and its status is Satisfied

smacdonald2008
smacdonald2008Accepted solution
New Participant
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

New Participant
June 2, 2017

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

where connect is serviceuser.

smacdonald2008
New Participant
May 30, 2017

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

Feike_Visser1
Employee
May 30, 2017

What do you see here? 

/system/console/components

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

New Participant
May 30, 2017

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

antoniom5495929
New Participant
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..
New Participant
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..

Feike_Visser1
Employee
May 29, 2017

But what is the issue you are having? That is not clear to me now.

New Participant
May 29, 2017

Yes, I have configured the user mapping configuration in system console. 

In osgi bundles, wherever the .loginAdministrstive(null) is called , i have replaced by below written codes:-

  1. @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){ } }