Highlighted

maven build generating an empty jar

jessicag5141490

17-02-2018

Hello,

I am starting with sling, and I am following an adobe tutorial to build a simple slingServlet using resourceType

My code is very simple, but seems to being ignored.

I was noting that when I do the maven build of the bundle, I am receiving the warning below but I am having success message on the process:

[WARNING] Bundle xxxxxx:xxxxx.core:bundle:1.0-SNAPSHOT : The JAR is empty: The instructions for the JAR named xxxxxx.core did not cause any content to be included, this is likely wrong

When I decompiled my jar, it has inside only the pom.xml, pom.properties and manifest,mf,

My packages strangely are not on the generated jar archive.

Has someone faced this same problem or has some idea of what this could be?

Thank you,

jessica

Replies

Highlighted

jessicag5141490

17-02-2018

Hi,

I would abble to resolve the jar problems, mas my servlet is still getting ignore.

My bundle is active, so I don't know what more should I have to do.

I just have this class, I am trying to access it with /content/my-website/my-page.groups.html

but it is not working

This is what I have for now:

@SlingServlet(methods = {"GET"},

metatype = true,

resourceTypes = {"resource/myresource"},

selectors = {"groups"})

public class ChangeURLServlet extends SlingAllMethodsServlet{

private static final long serialVersionUID = 2598426539166789515L;

   

    private static final Logger log = LoggerFactory.getLogger(ChangeURLServlet.class);

   

    @Override

    protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServerException, IOException {

      

     try

     {

         PrintWriter out = response.getWriter();

         out.println("<html><body>");

         out.println("<h1>This value was returned by an AEM Sling Servlet bound by using a Sling ResourceTypes property</h1>");

         out.println("</html></body>");

         response.getWriter().write("it called the servlet!");

     }

     catch(Exception e)

     {

         log.info(e.getMessage(),e);

     }

   }

}

Highlighted

Ratna_Kumar

MVP

17-02-2018

Hi,

I hope you have followed our HELPX article: Adobe Experience Manager Help | Binding Adobe Experience Manager Servlets to ResourceTypes properly

I have done this many times but I didn't encountered this issue. When I try to access the page as per article http://localhost:4502/content/submitPage.groups.html , the servlet is called for me.

Thanks,

Ratna Kumar.

Highlighted

jessicag5141490

18-02-2018

Yes! is this article that I am following, it seems very simple, but when I try on my application, nothing happens.

One different that I noted is that the jar that is being generated on the article has one thing more that is a package called metatype.

When I generate and decompile my jar, it does not has this package metatype.

I don't know if I am missing some configuration.

1421802_pastedImage_2.png

thanks for your help!

Highlighted

jessicag5141490

18-02-2018

Another thing that I am seeing is that when I create a page the resourceType of the page is, for example,

website/components/structure/pages/mypage I am using this original resourceType and the page works fine, but does not call the servlet.

If I try to change this resourceType for another name random, the page does not work and I have the error below:

org.apache.sling.servlets.get.impl.DefaultGetServlet No renderer for extension html, cannot render resource JcrNodeResource, type=bin/pages/mypage, superType=null,

I don't know what can I try anymore