Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

OSGI R7 annotation

Avatar

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
DIPEN1
Level 2

25-03-2019

Hi,

I have created a project using AEM Archetype 17 and followed this article. I am able to use other osgi R7 annotations like @ServiceDescription or @ServiceVendor. But I am not able to use @Activate on configuration like this:

@Activate

private MyServiceConfiguration config;

I am getting error '@Activate not applicable to field' in intelliJ idea and while maven build I am getting error 'annotation type not applicable to this kind of declaration'.

Replies

Avatar

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
DIPEN1
Level 2

25-03-2019

Feike Visser​ Could you please have a look. I guess its your article. I am using AEM 6.4, jdk 1.8, Maven 3.5.4.

Avatar

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

440 likes

Total Posts

1,016 posts

Correct Reply

115 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

440 likes

Total Posts

1,016 posts

Correct Reply

115 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile
Veena_Vikram
MVP

25-03-2019

DIPEN,

   Sorry. Feike is no more with us. Will check this soon

Thanks

Veena

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,077 likes

Total Posts

3,112 posts

Correct Reply

1,060 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,077 likes

Total Posts

3,112 posts

Correct Reply

1,060 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

25-03-2019

The error message is quite clear: You cannot annotate a field with the @Activate method, but only a method.

Jörg

Avatar

Avatar
Validate 1
Level 4
BrijeshYadav
Level 4

Likes

57 likes

Total Posts

97 posts

Correct Reply

19 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Establish
View profile

Avatar
Validate 1
Level 4
BrijeshYadav
Level 4

Likes

57 likes

Total Posts

97 posts

Correct Reply

19 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Establish
View profile
BrijeshYadav
Level 4

26-03-2019

@Dipen This might be helpful

https://blog.osgi.org/2018/03/osgi-r7-highlights-declarative-services.html

Activation Fields

In addition to supporting injecting activation objects using constructor injection, and also method injection via the activate method, DS 1.4 adds support for field injection of activation objects. A field of the type of an activation object can be annotated with Activate and SCR will inject the activation object into the field after object construction.

@Activate private ComponentContext context;
@Activate private BundleContext bc;

@Activate private Map<String,Object> componentProps;

@Activate private Props props;

Avatar

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
Gaurav-Behl
MVP

26-03-2019

check the version of maven-bundle-plugin (should be 4.1.0) or bnd plugin (should be 4.1) is the root cause?  Archetype 17 should have generated R7 versions but no harm in validating the effective pom/versions

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,260 likes

Total Posts

3,139 posts

Correct Reply

886 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,260 likes

Total Posts

3,139 posts

Correct Reply

886 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

26-03-2019

Guys,

The issue is, there are more than one jar which has Activate class, due to this the class which support @Actiavate annotation with field is not getting used.

To fix this issue, just update below dependency version to 7 in parent POM. and rebuild the project. Hope this will help.

Let me know if further issue, I am able to successfully build the project using R7 annotation.

     <dependency>

                <groupId>org.osgi</groupId>

                <artifactId>osgi.cmpn</artifactId>

                <version>7.0.0</version>

                <scope>provided</scope>

            </dependency>

Avatar

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
DIPEN1
Level 2

27-03-2019

Arun Patidar

With the changes to osgi.cmpn dependency version, build is successful but bundle is getting installed state. org.osgi.service.event is not resolved. org.osgi.service.event is imported as [1.4,2) whereas in AEM 6.4 version 1.3.1 is available which is exported by Apache Felix EventAdmin bundle.

So I am able to build but not deploy.

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,260 likes

Total Posts

3,139 posts

Correct Reply

886 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,260 likes

Total Posts

3,139 posts

Correct Reply

886 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

27-03-2019

Hi Add below dependency as well in parent and core pom

<dependency>

<groupId>org.osgi</groupId>

<artifactId>org.osgi.compendium</artifactId>

<version>5.0.0</version>

<scope>provided</scope>

</dependency>

Please let me know, I can share my package.

Edit:

you should use below dependency instead of above (org.osgi.compendium)

<dependency> 

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

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

    <version>1.4.10</version> 

    <scope>provided</scope> 

</dependency>

Avatar

Avatar
Validate 1
Level 7
Hemant_arora
Level 7

Likes

92 likes

Total Posts

290 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 50
View profile

Avatar
Validate 1
Level 7
Hemant_arora
Level 7

Likes

92 likes

Total Posts

290 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 50
View profile
Hemant_arora
Level 7

28-03-2019

reordering the dependencies in core pom worked for me. I faced the same issue.

CORE POM

<dependencies>

<dependency>

  <groupId>org.osgi</groupId>

  <artifactId>org.osgi.service.component</artifactId>

  </dependency>

  <dependency>

  <groupId>org.osgi</groupId>

  <artifactId>org.osgi.service.component.annotations</artifactId>

</dependency>

<dependency>

  <groupId>org.osgi</groupId>

  <artifactId>org.osgi.service.metatype.annotations</artifactId>

</dependency>

        <!-- OSGi Dependencies -->

        <dependency>

            <groupId>org.osgi</groupId>

            <artifactId>osgi.core</artifactId>

        </dependency>

        <dependency>

            <groupId>org.osgi</groupId>

            <artifactId>osgi.cmpn</artifactId>

        </dependency>

        <dependency>

            <groupId>org.osgi</groupId>

            <artifactId>osgi.annotation</artifactId>

        </dependency>

.......................................

PROJECT POM:

add the following deps as given in articles:

<dependency>

  <groupId>org.osgi</groupId>

  <artifactId>org.osgi.service.component.annotations</artifactId>

  <version>1.4.0</version>

  <scope>provided</scope>

</dependency>

<dependency>

  <groupId>org.osgi</groupId>

  <artifactId>org.osgi.annotation</artifactId>

  <version>6.0.0</version>

  <scope>provided</scope>

</dependency>

<dependency>

  <groupId>org.osgi</groupId>

  <artifactId>org.osgi.service.metatype.annotations</artifactId>

  <version>1.4.0</version>

  <scope>provided</scope>

</dependency>

<dependency>

  <groupId>org.osgi</groupId>

  <artifactId>org.osgi.service.component</artifactId>

  <version>1.4.0</version>

  <scope>provided</scope>

</dependency>