Unable to use Runmode config from a Service using @OSGIService annotation | Community
Skip to main content
Level 2
May 20, 2024
Solved

Unable to use Runmode config from a Service using @OSGIService annotation

  • May 20, 2024
  • 2 replies
  • 753 views

Hello, 

I have a codebase in AEM6.5 that cannot read a OSGi config, using org.osgi.service.cm.ConfigurationAdmin api, when @OSGIService is used instead of @3214626.
I see that when annotated with @OSGIService, the reference object is not empty, but the Config is always returned as NULL, though they are confirmed to exist.

 

The same code works when used with @3214626 annotation & on other codebase the config values are read using "@OSGIService" inside a @Model class. Hence I am unable to connect these dots, so kindly enlight me to understand whats happening in the background.

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 EstebanBustamante

Hi,

 

The @OSGIService annotation is specific for sling models, you cannot use it outside a sling model, in other words, it is expected to get null if you are using this annotation within an OSGI service. Check the official doc: https://sling.apache.org/apidocs/sling8/org/apache/sling/models/annotations/injectorspecific/OSGiService.html

 

Hope this helps

2 replies

Manu_Mathew_
Community Advisor
Community Advisor
May 20, 2024

@prasanthanandharaj Have you checked the following- 

Make sure the bundle is active;

Make sure the component is active;

Check for unresolvable dependencies in the bundle;

Check for unsatisfied references in the component;

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
May 20, 2024

Hi,

 

The @OSGIService annotation is specific for sling models, you cannot use it outside a sling model, in other words, it is expected to get null if you are using this annotation within an OSGI service. Check the official doc: https://sling.apache.org/apidocs/sling8/org/apache/sling/models/annotations/injectorspecific/OSGiService.html

 

Hope this helps

Esteban Bustamante