Hi All,
I have created the sling servlet in AMS Cloud Version SDK, For that i am facing servlet hit issue as it is in satisfied state and not getting into Active state.
I've checked following basic steps for servlet properly registered or not.
-Bundle is active.
-Servlet is registered i.e, i am able to see at system/console/components
I've seen some fixes for it as below but still the issue is not resolved
-I was trying to resolve the path at /system/console/servletresolver. Even /bin also not resolved.
-I was trying a bunch of different paths like /bin, /bin/test , /bin/groupServlet and those paths are already whitelisted at Apache Sling Servlet/Script Resolver and Error Handler.
-I have tried with resource base servlet and facing same issue not resolved error.
- tried with empty servlet as well with only sysout message post removing service reference.
Does anyone have any ideas or other things I can check for as to why this would not work?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
I tried with your servlet, It works for me.
I changed method from Post to Get, just for testing
Hi @merajsid
Here is the way you can debug more:
Hope this helps.
Thanks,
Kiran Vedantam.
Hi,
Could you please share the servlets skelton code?
Without seeing code, it is hard to tell what could be the potential issue. Most of the time it is related to code.
Hi Arun,
Please see below code - we have removed logic part and trying with this blank servlet first. Also renamed project folder with "abc" rest other parts are same. Where "abc" is project folder and there is common folder using core components.
package com.ace.core.product.search.servlets;
import java.io.IOException;
import javax.servlet.Servlet;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.HttpConstants;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.apache.sling.servlets.annotations.SlingServletResourceTypes;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.propertytypes.ServiceDescription;
@component(service = { Servlet.class }, immediate = true)
@SlingServletResourceTypes(
resourceTypes="abc/components/page",
methods=HttpConstants.METHOD_POST,
selectors = "productSearch")
@ServiceDescription("Product Search Servlet")
public class ProductSearchServlet extends SlingAllMethodsServlet {
private static final long serialVersionUID = 1L;
@activate
public void activate(){
}
@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException {
response.getWriter().println("Hello");
}
}
Hi @merajsid,
If "abc/components/page" is the resourceType of your site content page say, /content/abc/us/en (jcr:content of the page has the resourceType), then accessing like http://localhost:4502/content/abc/us/en/jcr:content.productSearch.html will execute the servlet doPost per your servlet registration.
Hi,
I tried with your servlet, It works for me.
I changed method from Post to Get, just for testing