Cannot register service with ModelFactory reference in AemContext

Description

I'm trying to test one of my services, which uses OSGi annotation @Reference to inject org.apache.sling.models.factory.ModelFactory.

I'm using AemMocks 2.3.2 (also tested with 2.2.12) and get following error on attempt of service registration:

aemContext.registerInjectActivateService(new MyServiceImpl());

org.apache.sling.testing.mock.osgi.ReferenceViolationException: Multiple matches found for unary reference 'modelFactory' for class ../MyServiceImpl.class

Debugger says that there are 110 matching services of ModelFactory are registered, so it cannot pick any particular one.

It works fine with any other References we inject in our project.

Environment

None

Status

Assignee

Stefan Seifert

Reporter

Gleb Rimmel

Labels

None

Components

Fix versions

Affects versions

AEM Mocks 2.2.12
AEM Mocks 2.3.2

Priority

Major
Configure