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

The attribute reference is undefined for the annotation type Component

Avatar

Avatar
Level 1
sai1007
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
sai1007
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
sai1007
Level 1

11-06-2021

Hi,

 

I am not able to find solution for above error. please find my code snippet below

 

 

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;

@component(/* service = ConfigUtil.class, */ immediate = true,

reference = {
@reference(name = "configutil",  bind = "bindAssetDetailsSelector" 
unbind = "unbindAssetDetailsSelector", service = DataPowerUrlUtil.class,
policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE
) }
)

 

using maven-bundle-plugin version 4.2.1,  <artifactId>org.osgi.service.component.annotations</artifactId> verion 1.4.0,

R7 annotation

 

Thanks,

Sai

Accepted Solutions (0)

Answers (4)

Answers (4)

Avatar

Avatar
Ignite 1
MVP
Ankur_Khare
MVP

Likes

155 likes

Total Posts

370 posts

Correct Reply

57 solutions
Top badges earned
Ignite 1
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile

Avatar
Ignite 1
MVP
Ankur_Khare
MVP

Likes

155 likes

Total Posts

370 posts

Correct Reply

57 solutions
Top badges earned
Ignite 1
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile
Ankur_Khare
MVP

17 hours ago

Avatar

Avatar
Give Back 10
MVP
shelly-goel
MVP

Likes

173 likes

Total Posts

323 posts

Correct Reply

87 solutions
Top badges earned
Give Back 10
Validate 1
Shape 1
Ignite 1
Give Back 5
View profile

Avatar
Give Back 10
MVP
shelly-goel
MVP

Likes

173 likes

Total Posts

323 posts

Correct Reply

87 solutions
Top badges earned
Give Back 10
Validate 1
Shape 1
Ignite 1
Give Back 5
View profile
shelly-goel
MVP

18 hours ago

I think you have to use @OsgiService annotation instead of @reference

Avatar

Avatar
Boost 5
Level 5
Ritesh_M
Level 5

Likes

74 likes

Total Posts

67 posts

Correct Reply

19 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Boost 5
Level 5
Ritesh_M
Level 5

Likes

74 likes

Total Posts

67 posts

Correct Reply

19 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile
Ritesh_M
Level 5

18 hours ago

 

Hi @sai1007 ,

 

Which Maven Archetype you are using in your project? I am able to include @Reference annotation inside @Component annotation without any issue. I am using 6+ version of OSGI dependencies. Try using below if it resolves your issue-
(Also, I see there is one comma missing after 'bind = "bindAssetDetailsSelector" ' and small 'r' for Reference annotation but I believe those are just typos.)

 
<!-- OSGi Dependencies -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.core</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.annotation</artifactId>
<version>6.0.1</version>
<scope>provided</scope>
</dependency>

Avatar

Avatar
Establish
Level 2
kchaurasiya
Level 2

Likes

10 likes

Total Posts

19 posts

Correct Reply

2 solutions
Top badges earned
Establish
View profile

Avatar
Establish
Level 2
kchaurasiya
Level 2

Likes

10 likes

Total Posts

19 posts

Correct Reply

2 solutions
Top badges earned
Establish
View profile
kchaurasiya
Level 2

11-06-2021

Hi Sai, Just check the below and try.

 

@Component(service =  ConfigUtil.class, configurationPolicy = ConfigurationPolicy.REQUIRE, immediate = true)
@Designate(ocd = ConfigUtilImpl.Config.class)

Thanks.