@Reference is not working getting null | Community
Skip to main content
October 16, 2015
Solved

@Reference is not working getting null

  • October 16, 2015
  • 2 replies
  • 3113 views

Hi friends,

 Am getting the null when injecting the resolverFactory object in Java class through Fleix Annotations(@Reference).

How i can use the sling and cq implicit object java class.It can be useful in JSP.But how in java class???

Please tell me a solution

 

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 Yogesh_Upadhyay

In Java recommended approach is to use @reference to get a service reference. If you are getting null for  resolverFactory in your service (Your class should be service as well) please create a daycare ticket with steps to reproduce this issue. 

Other way to get a reference would be in your activate method of service (Your class) using bundlecontext (Similar to this http://www.knopflerfish.org/releases/current/docs/javadoc/org/osgi/framework/BundleContext.html#getService(org.osgi.framework.ServiceReference))

Yogesh

2 replies

Yogesh_Upadhyay
Yogesh_UpadhyayAccepted solution
October 16, 2015

In Java recommended approach is to use @reference to get a service reference. If you are getting null for  resolverFactory in your service (Your class should be service as well) please create a daycare ticket with steps to reproduce this issue. 

Other way to get a reference would be in your activate method of service (Your class) using bundlecontext (Similar to this http://www.knopflerfish.org/releases/current/docs/javadoc/org/osgi/framework/BundleContext.html#getService(org.osgi.framework.ServiceReference))

Yogesh

October 16, 2015

Yogesh Upadhyay wrote...

In Java recommended approach is to use @reference to get a service reference. If you are getting null for  resolverFactory in your service (Your class should be service as well) please create a daycare ticket with steps to reproduce this issue. 

Other way to get a reference would be in your activate method of service (Your class) using bundlecontext (Similar to this http://www.knopflerfish.org/releases/current/docs/javadoc/org/osgi/framework/BundleContext.html#getService(org.osgi.framework.ServiceReference))

Yogesh

 

Yes.For @Service annotated class itself am getting the null.

Why am getting null..

Thanks in advance