Felix scr annotations are not working in aem 6.2 | Community
Skip to main content
Level 2
July 12, 2017
Solved

Felix scr annotations are not working in aem 6.2

  • July 12, 2017
  • 5 replies
  • 5984 views

Hi,

we migrated from cq 5.6.1 to AEM 6.2 and observed that few services are not working in AEM 6.2.

@component and @service annotations are not making our class registered as component and service in felix-->OSGI--->Services.

The dependencies in our POM is as below:

<dependency>

<groupId>org.apache.felix</groupId>

<artifactId>org.apache.felix.scr.annotations</artifactId>

<version>1.9.0</version>

<scope>provided</scope>

</dependency>

Does anybody know why it happened and how to fix it?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Techaspect_Solu

Hi krishc76025392

As a reference you can check the Plugins and dependencies as below and try:

<!-- Apache Felix SCR Plugin -->

<plugin>

               <groupId>org.apache.felix</groupId>

               <artifactId>maven-scr-plugin</artifactId>

               <version>1.20.0</version>

          <executions>

               <execution>

               <id>generate-scr-scrdescriptor</id>

               <goals>

                    <goal>scr</goal>

               </goals>

     <configuration>

<!-- Private service properties for all services. -->

          <properties>

               <service.vendor>Adobe</service.vendor>

          </properties>

     </configuration>

               </execution>

          </executions>

<configuration>

               <outputDirectory>${project.build.directory}/classes</outputDirectory>

</configuration>

          <dependencies>

               <dependency>

                         <groupId>org.slf4j</groupId>

                         <artifactId>slf4j-simple</artifactId>

                         <version>1.5.11</version>

               </dependency>

          </dependencies>

</plugin>

<!-- Apache Felix Bundle Plugin -->

<plugin>

           <groupId>org.apache.felix</groupId>

           <artifactId>maven-bundle-plugin</artifactId>

           <version>2.5.3</version>

           <inherited>true</inherited>

</plugin>

<!-- OSGi Dependencies -->

<dependency>

          <groupId>org.apache.felix</groupId>

          <artifactId>org.apache.felix.scr</artifactId>

          <version>2.0.10</version>

            <scope>provided</scope>

</dependency>

<dependency>

          <groupId>org.apache.felix</groupId>

          <artifactId>org.apache.felix.scr.annotations</artifactId>

          <version>1.9.6</version>

</dependency>

You can take a look at adobe post also.

Thanks,

Techaspect Solutions Pvt Ltd.

5 replies

Rajeev_Kumar
Level 3
July 12, 2017

Hi,

One use case I faced in Aem 6.2 is if any of the classes is using annotations from package 'org.osgi.service.component.annotations', annotations of package 'org.apache.felix.scr' are ignored by Aem.

So, you can take a look at the codebase if any class is using annotation from 'org.osgi'  annotation package.

Feike_Visser1
Adobe Employee
Adobe Employee
July 12, 2017

Indeed, can you share the imports too from your class.

Techaspect_Solu
Techaspect_SoluAccepted solution
Level 7
July 12, 2017

Hi krishc76025392

As a reference you can check the Plugins and dependencies as below and try:

<!-- Apache Felix SCR Plugin -->

<plugin>

               <groupId>org.apache.felix</groupId>

               <artifactId>maven-scr-plugin</artifactId>

               <version>1.20.0</version>

          <executions>

               <execution>

               <id>generate-scr-scrdescriptor</id>

               <goals>

                    <goal>scr</goal>

               </goals>

     <configuration>

<!-- Private service properties for all services. -->

          <properties>

               <service.vendor>Adobe</service.vendor>

          </properties>

     </configuration>

               </execution>

          </executions>

<configuration>

               <outputDirectory>${project.build.directory}/classes</outputDirectory>

</configuration>

          <dependencies>

               <dependency>

                         <groupId>org.slf4j</groupId>

                         <artifactId>slf4j-simple</artifactId>

                         <version>1.5.11</version>

               </dependency>

          </dependencies>

</plugin>

<!-- Apache Felix Bundle Plugin -->

<plugin>

           <groupId>org.apache.felix</groupId>

           <artifactId>maven-bundle-plugin</artifactId>

           <version>2.5.3</version>

           <inherited>true</inherited>

</plugin>

<!-- OSGi Dependencies -->

<dependency>

          <groupId>org.apache.felix</groupId>

          <artifactId>org.apache.felix.scr</artifactId>

          <version>2.0.10</version>

            <scope>provided</scope>

</dependency>

<dependency>

          <groupId>org.apache.felix</groupId>

          <artifactId>org.apache.felix.scr.annotations</artifactId>

          <version>1.9.6</version>

</dependency>

You can take a look at adobe post also.

Thanks,

Techaspect Solutions Pvt Ltd.

Level 2
July 12, 2017

Hi Techaspect,

we followed the dependencies suggested by you and now services are coming up.

Thank you for your suggestion..

Regards,

Krishchopps.

viveksachdeva
Community Advisor
Community Advisor
July 13, 2017

I dont think, all changes are needed. Just 2 dependency versions need to be updated.. Here is a blog that talks about similar issue: Issues while Migrating from Java6 to Java8 in AEM 6.1 | TO THE NEW Blog