Expand my Community achievements bar.

SOLVED

Felix scr annotations are not working in aem 6.2

Avatar

Level 2

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?

1 Accepted Solution

Avatar

Correct answer by
Level 7

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.

View solution in original post

5 Replies

Avatar

Level 3

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.

Avatar

Employee

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

Avatar

Correct answer by
Level 7

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.

Avatar

Level 2

Hi Techaspect,

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

Thank you for your suggestion..

Regards,

Krishchopps.

Avatar

Level 7

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