I have created the below servlet. I have added the servlet path in Apache sling servlet resolver. I am firing an ajax call with the url same as the path of servlet. But the servlet is getting ignored or not getting registered.
Could any one please provide some inputs for getting the servlet registered. I checked the servletresolver console and it says servlet does not exist.
PFB code.
import java.io.IOException; import java.rmi.ServerException; import com.aem.poc.core.service.WaterHeightService; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ValueMap; import org.apache.sling.jcr.api.SlingRepository; import java.util.*; //DS Annotations import org.apache.sling.servlets.annotations.SlingServletPaths; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import javax.servlet.Servlet; import org.osgi.framework.Constants; import org.apache.sling.api.servlets.HttpConstants; import org.slf4j.LoggerFactory; import org.slf4j.Logger; @SlingServletPaths("/bin/heightSearchServlet") @Component(service=Servlet.class) public class WaterHeightServlet extends org.apache.sling.api.servlets.SlingAllMethodsServlet { //private static final long serialVersionUID = 2598426539166789515L; @Reference private SlingRepository repository; @Reference private WaterHeightService whs; List<Map> waterHeightList = new ArrayList<>(); public void bindRepository(SlingRepository repository) { this.repository = repository; } @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServerException, IOException { try { String requiredHeight = request.getParameter("id"); waterHeightList.addAll(whs.getHeightList()); Logger log = LoggerFactory.getLogger(WaterHeightServlet.class); //log.debug("passed param value is"+requiredHeight); for (Map item: waterHeightList) { log.debug("map item is"+item.get("datevalue")); } //response . write() trturn the data } catch(Exception e) { e.printStackTrace(); } } }