title: AEM 6.3, wcm.io: register (Mock)ResourceResolverFactory issue
body: <p>I am using wcm.io to create an AEMContext and I am able to the a simple Sling model that has no reference to other services. I do want to add a reference to my AliasService so I register/activate it in my context setup:</p>
  
  <pre><code>aemContext.registerInjectActivateService(new AliasService());
  </code></pre>
  
  <p>AliasService:</p>
  
  <pre><code>public class AliasService {
  
  @Reference
  private AutoClosableResourceResolverFactory resourceResolverFactory;
  
  ...
  </code></pre>
  
  <p>As you can see this service has a reference to AutoClosableResourceResolverFactory so I register/activate is as well:</p>
  
  <pre><code>aemContext.registerInjectActivateService(AutoClosableResourceResolverFactory.class, new AutoClosableResourceResolverFactory());
  </code></pre>
  
  <p>AutoClosableResourceResolverFactory:</p>
  
  <pre><code>public class AutoClosableResourceResolverFactory {
  
  @Reference
  private ResourceResolverFactory delegate;
  
  ...
  </code></pre>
  
  <p>The service depends on ResourceResolverFactory so I inject/activate it using the 'MockResourceResolverFactory' (final list of injects):</p>
  
  <pre><code>aemContext.registerInjectActivateService(ResourceResolverFactory.class, new MockResourceResolverFactory());
  aemContext.registerInjectActivateService(AutoClosableResourceResolverFactory.class, new AutoClosableResourceResolverFactory());
  aemContext.registerInjectActivateService(new AliasService());
  </code></pre>
  
  <p>I now get the following error if I try to execute my test:</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: args must be an even number of name/values:[org.apache.sling.testing.resourceresolver.MockResourceResolverFactory@7fb95505]
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Vx81i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vx81i.png" alt="enter image description here"></a></p>
  
  <p>I have no idea how to fix this or what is causing this, all help is greatly appreciated!</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The fix Jens provided totally worked for my older services (Felix annotation based -> org.apache.felix.scr.annotations.Component). When I try this for a newer service (OSGI annotation based -> org.osgi.service.component.annotations.Component), I get an error.</p>
  
  <p>Service:</p>
  
  <pre><code>...
  import org.osgi.service.component.annotations.Component;
  
  @Component(service = TestService.class, immediate = true, property = {
      Constants.SERVICE_DESCRIPTION + "=" + "Test Service",
      Constants.SERVICE_VENDOR + "=" + BundleConstants.SERVICE_VENDOR
  })
  public class TestServiceImpl implements TestService {
  
  @Override
  public String getValue() {
      return "test-value-from-service";
     }
  }
  </code></pre>
  
  <p>Sling Model:</p>
  
  <pre><code>@OSGiService
  private TestService testService;
  
  public String getValue(){
     return testService.getValue();
  }
  </code></pre>
  
  <p>Register:</p>
  
  <pre><code>TestService testService = aemContext.registerInjectActivateService(new TestServiceImpl());
  </code></pre>
  
  <p>Error:</p>
  
  <p>Caused by: org.apache.sling.testing.mock.osgi.NoScrMetadataException: No OSGi SCR metadata found for class com.asadventure.core.service.TestServiceImpl</p>
  
  <p><a href="https://i.stack.imgur.com/MhMMS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MhMMS.png" alt="enter image description here"></a></p>
  
  <p>What am I missing?</p>