ActiveObjects: 2 instances?!

I have spent a bit of time looking into this one.

I have a set of services that use annotations for components.

A bunch of them use ActiveObjects.

The services work great in a unit-test environment.  In that instance I have a memory-based ActiveObjects that is used.

 

However, when trying to use 'atlas-run' I run into an issue.

I get the following error.

INFO] [talledLocalContainer] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'predicateService': Unsatisfied dependency expressed through constructor argument with index 0 of type 
[com.atlassian.activeobjects.external.ActiveObjects]: : No qualifying bean of type [com.atlassian.activeobjects.external.ActiveObjects] is defined: expected single matching bean but found 2: ao_osgi,activeObjects; 
nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.atlassian.activeobjects.external.ActiveObjects] is defined: expected single matching bean but found 2: ao_osgi,activeObjects

 

The code I have now looks like this (I added @Scan just now, to no avail.

@Scanned
@Component
@ExportAsService({PredicateService.class})
@Named("predicateService")
public class PredicateServiceImpl implements PredicateService {

    Logger.Log log = Logger.getInstance(PredicateServiceImpl.class);

    @ComponentImport
    private final ActiveObjects ao;

    @Inject
    public PredicateServiceImpl(ActiveObjects ao) {
        this.ao = ao;
    }

 

I have read about similar situations encountered in Spring in general, tried a few things, nothing seemed to work.  

Any advice, admonitions etc are appreciated!

 

1 answer

I swapped @ComponentImport with @Qualifier (the one that takes a value), and things seem happier.

I removed @Scanned as well.

Is this correct form?  

Do others encounter the need for @Qualifier sometimes?  

 

@Component
@ExportAsService({PredicateService.class})
@Named("predicateService")
public class PredicateServiceImpl implements PredicateService {

    Logger.Log log = Logger.getInstance(PredicateServiceImpl.class);

    @Qualifier("activeObjects")
    private final ActiveObjects ao;

    @Inject
    public PredicateServiceImpl(ActiveObjects ao) {
        this.ao = ao;
    }

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

280 views 11 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you