Not able to inject ResouceResolverFactory

Avatar

Avatar

umeshj24393

Avatar

umeshj24393

umeshj24393

27-05-2017

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

View Entire Topic

Avatar

Avatar

umeshj24393

Avatar

umeshj24393

umeshj24393

29-05-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..