How to Resolve a Maven-scr-Plugin Error in AEM


The idea for this article on resolving a Maven-scr-Plugin Error in AEM came about while building an AEM project using the Maven command. When we encountered this problem, we decided to explain the cause and the way to solve this error.

mvn clean install -P <Profile Name>
The Maven-scr-plugin error description is as shown below
[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.7.4:scr (generate-scr-descriptor) on project blog-bundle: SCR Descriptor parsing had failures (see log) -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
[ERROR] After correcting the problems, you can resume the build with the command

[ERROR]   mvn <goals> -rf :blog-bundle


Cause of Maven-scr-Plugin error
Most of the time this Maven-scr-pugin error occurs when you use the following two annotations together –
@SlingServlet and @Component same class.
For Example, if your coding syntax is
@SlingServlet(path="/bin/blog" extension="html")
Class TestServlet extends SlingSafeMethodsServlet { /*  ----------------------- */ }


In this case you will get that errorbecause @SlingServlet has “generateComponent” property and by default its value is “true” so ideally you don’t provide the @Component annotation.

How to resolve this Maven issue
There are two ways to resolve this issue –
  1. Remove @Component annotation while creating Sling Servlet.
  2. The issues with the first solution are –
    1. Unable to activate this Sling Servlet immediately: The timing of activation of this Sling Servlet is totally dependent on Felix implementation. This means it may or may not be in active state after deploying the package.
    2. We are not able to use immediate, enabled metatype and other properties provided by @Component.

The preferred way to use these annotations is
@SlingServlet(path="/bin/blog" extension="html", generateComponent=false)
Class TestServlet extends SlingSafeMethodsServlet { /*  ----------------------- */ }

I hope this article helped you understand the reason for Maven-scr-Plugin Error in AEM and how to resolve this issue.

You can also read about another Maven issue – Maven Dependencies Version Issue in AEM available in our Blog.

Share it:

Argil DX Media

November 25, 2014

Leave a Comment

Related Posts