Null sling repository
I have a class defined as follows:
@Component @Service public class CalendarServiceImpl implements CalendarService { static private final org.slf4j.Logger logger = LoggerFactory.getLogger(CalendarServiceImpl.class); @Reference private SlingRepository repository; public void bindRepository(SlingRepository repository) { this.repository = repository; } private Session _session; private Session getSession() { if (_session == null || !_session.isLive()) { try { _session = this.repository.loginAdministrative(null); } catch (RepositoryException e) { logger.error(e.getMessage()); } } return _session; } }When i try to instantiate the class using the following code from a JSP:
CalendarService calendarService = sling.getService(CalendarService.class);
And call a method which uses the Session variable, i receive and error telling me that the "repository" variable is NULL and therefore the component doesn't function as intended.
The strangest part about this is that it works fine on our Author instance, but doesn't work on the Publish instance.
Any help would be appreciated.