Felix scr annotations are not working in aem 6.2 | Community
Skip to main content
Level 2
Jul 12, 2017 10:05 AM UTC
Solved

Felix scr annotations are not working in aem 6.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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Techaspect_Solu
Techaspect_SoluAccepted solution
Level 7
Jul 12, 2017 12:37 PM UTC

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

viveksachdeva
New Participant
Jul 13, 2017 6:51 AM UTC

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

Translate
Level 2
Jul 12, 2017 1:42 PM UTC

Hi Techaspect,

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

Thank you for your suggestion..

Regards,

Krishchopps.

Translate
Techaspect_Solu
Techaspect_SoluAccepted solution
Level 7
Jul 12, 2017 12:37 PM UTC

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.

Translate
Feike_Visser1
Employee
Jul 12, 2017 12:00 PM UTC

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

Translate
Rajeev_Kumar
Level 3
Jul 12, 2017 11:21 AM UTC

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.

Translate