Maven-scr-Plugin Error in AEM

In this blog, I will explain an error occurred when we build an AEM project using –



maven command.

Error description is as shown below – 

 

Cause of this error – 
Most of the time this error occur because of the use of these two annotations –
@SlingServlet & @Component same class.
For Example, If your coding syntax is  –

 

 
In this case you will get that error, because @SlingServlet have a property “generateComponent” by default it’s value is “true” so ideally you don’t provide the @Component annotation.
How to Resolve this issue – 
There are two ways to resolve this issue –
  1. Remove @Component annotation while creating Sling Servlet.
  2. The issue with first solution are –
    1. We are not able to activate this Sling Servlet immediately, It is totally dependent on Felix implementation when it will activate this Sling Servlet. i.e. it may or may not be in active state after deploying the package.
    2. We are not able to use immediate, enabled metatype & other properties provided by  @Component

Preferred way to use these annotations is –

I hope it helps.. Happy Coding.

Ankur Chauhan.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *