Expand my Community achievements bar.

SOLVED

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

Avatar

Level 2

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 @reference.
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 @reference 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.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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/OSGiSer...

 

Hope this helps



Esteban Bustamante

View solution in original post

2 Replies

Avatar

Community Advisor

@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;

Avatar

Correct answer by
Community Advisor

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/OSGiSer...

 

Hope this helps



Esteban Bustamante