Hi All,
My sling servlet is not working as soon as i add
@Reference in it, otherwise it works fine
Below is the servlet code, i have create custom configuration as per the AEM6.4 standards(one @Interface class, one Interface class, one Impl class with proper annotations(org.osgi.service.component.annotations))
@Component(service = Servlet.class,
property = { Constants.SERVICE_DESCRIPTION + "=Simple Demo Servlet",
"sling.servlet.methods=" + HttpConstants.METHOD_GET,
"sling.servlet.paths=" + "/bin/testservlet" }
)
public class TestServlet extends SlingAllMethodsServlet {
private static final long serialVersionUID = 1L;
@Reference
MySimpleService mySimpleService;
private static final Logger logger =
LoggerFactory.getLogger(TestServlet.class);
@Override
protected void doGet(final SlingHttpServletRequest req, final
SlingHttpServletResponse resp) throws ServletException, IOException {
logger.info("Inside doGet!!!");
try {
logger.info("Name ::: "+mySimpleService.getMyName());
resp.getWriter().write(mySimpleService.getMyName()); }
catch(Exception ex) {
logger.error("Error in doGet ::: ", ex);
}
}
}
Please advise, any help is highly appreciated.
Thanks,
Pradeep