Expand my Community achievements bar.

OSGI 6 @Reference annotation not working

Avatar

Level 1

Hello,

We are upgrading from 6.3 to 6.4 and then immediately to 6.5. I'm working on updating our codebase and am having an issue with replacing the @Reference annotation from Felix to OSGI. I have been able to switch all other annotations, but looking at examples I shouldn't have to change how @Reference works.

import com.banner.aem.services.ConfigAsJsonService;
import com.banner.aem.services.CookieService;
import com.banner.aem.services.GenericRestService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component(service = ConfigAsJsonService.class,immediate = true)

public class ConfigAsJsonServiceImpl implements ConfigAsJsonService{

   private static final Logger LOG = LoggerFactory.getLogger(ConfigAsJsonServiceImpl.class);

   @org.osgi.service.component.annotations.Reference
   GenericRestService genericRestService;

   @org.osgi.service.component.annotations.Reference
   CookieService cookieService;

   @Override
   public String getConfigJsonString() {

 

   }

}

I get this error: "The annotation @Reference is disallowed for this location".  Does anyone have any fixes?

Thank you

0 Replies