Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

@Reference is not working getting null

Avatar

Former Community Member

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

1 Accepted Solution

Avatar

Correct answer by
Level 5

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#getS...))

Yogesh

View solution in original post

2 Replies

Avatar

Correct answer by
Level 5

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#getS...))

Yogesh

Avatar

Former Community Member

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#getS...))

Yogesh

 

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

Why am getting null..

Thanks in advance