Hi,
I am trying to compile and build the below servlet in CRXde lite and it is not getting built (though it is not recommended).
package foo.bar;
import java.io.IOException;
import javax.servlet.ServletException;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.sling.SlingServlet;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
@Component()
@Service()
@SlingServlet(paths="/bin/userlist", metatype = false)
public class UserServlet extends SlingAllMethodsServlet {
private static final long serialVersionUID = -9067150309356760626L;
//private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Reference
private ResourceResolverFactory resolverFactory;
@Override
protected void doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException,
IOException {
userListJSON(request, response);
}
@Override
protected void doPost(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException,
IOException {
userListJSON(request, response);
}
protected void userListJSON(SlingHttpServletRequest request,
SlingHttpServletResponse response){
response.setContentType("application/json");
}
}
It is throwing the below 2 errors. Could anyone please help in resolving this. Please note that I am not able to create this using Eclipse and maven due to some proxy issues at the moment.
1. Class has more than one component definition. Check the annotations and merge the definitions to a single definition.
2. SCR Descriptor parsing had failures (see log)
Solved! Go to Solution.
Views
Replies
Total Likes
CRXDE lite is not a good way to build OSGi bundles (either services or servlets). Your code looks fine and should work. Take a look at this old article that talks about using CRXDE lite to build OSGi:
https://helpx.adobe.com/experience-manager/using/creating-osgi-bundles-digital-marketing.html
Also notice the note in this article:
Update: It is recommended that you no longer use CRXDE to create OSGi bundles for AEM. Instead use Maven. For information, see Creating your first AEM Service using an Adobe Maven Archetype project.
As soon as you can - i recommend moving over to Maven ASAP.
Views
Replies
Total Likes
CRXDE lite is not a good way to build OSGi bundles (either services or servlets). Your code looks fine and should work. Take a look at this old article that talks about using CRXDE lite to build OSGi:
https://helpx.adobe.com/experience-manager/using/creating-osgi-bundles-digital-marketing.html
Also notice the note in this article:
Update: It is recommended that you no longer use CRXDE to create OSGi bundles for AEM. Instead use Maven. For information, see Creating your first AEM Service using an Adobe Maven Archetype project.
As soon as you can - i recommend moving over to Maven ASAP.
Views
Replies
Total Likes
Views
Replies
Total Likes
Have you tried using code in an example article(see below), any reason you are declaring the servlet as a service and a component? Just take the class below and have a very simple doGet method.
https://helpx.adobe.com/experience-manager/using/sling_servlet_mbean.html
Views
Replies
Total Likes